Skip to content
This repository was archived by the owner on Jan 29, 2022. It is now read-only.

Commit cdace7e

Browse files
authored
Merge pull request #151 from newrelic/fix-publishing-0-13-1
Fix publishing to compile with Java 8
2 parents 4f3571c + a8613b9 commit cdace7e

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

build.gradle.kts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,6 @@ apply(plugin = "signing")
1414

1515
apply(plugin = "com.github.sherter.google-java-format")
1616

17-
tasks.withType<JavaCompile>().configureEach {
18-
javaCompiler.set(javaToolchains.compilerFor {
19-
languageVersion.set(JavaLanguageVersion.of(8))
20-
})
21-
}
22-
23-
tasks.withType<Test>().configureEach {
24-
javaLauncher.set(javaToolchains.launcherFor {
25-
languageVersion.set(JavaLanguageVersion.of(11))
26-
})
27-
}
28-
2917
allprojects {
3018
group = "com.newrelic.telemetry"
3119

@@ -38,11 +26,21 @@ allprojects {
3826
// this is only needed for the working against unreleased otel-java snapshots
3927
maven("https://oss.jfrog.org/artifactory/oss-snapshot-local")
4028
}
41-
tasks.withType<Test> {
29+
tasks.withType<JavaCompile>().configureEach {
30+
// compile all projects with Java 8
31+
javaCompiler.set(javaToolchains.compilerFor {
32+
languageVersion.set(JavaLanguageVersion.of(8))
33+
})
34+
}
35+
tasks.withType<Test>().configureEach {
4236
useJUnitPlatform()
4337
testLogging {
4438
events("passed", "skipped", "failed")
4539
}
40+
// run tests in all projects with Java 11
41+
javaLauncher.set(javaToolchains.launcherFor {
42+
languageVersion.set(JavaLanguageVersion.of(11))
43+
})
4644
}
4745
}
4846

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Passing in -Prelease=true will render a non-snapshot version.
55
# All other values (including unset) will render a snapshot version.
66

7-
baseVersion = 0.14.0
7+
baseVersion = 0.13.1
88

99
# set this to true to enable using a local sonatype (for debugging publishing issues)
1010
# (start a local sonatype in docker with this command: $ docker run -d -p 8081:8081 --name nexus sonatype/nexus3)

opentelemetry-exporters-newrelic/src/main/java/com/newrelic/telemetry/opentelemetry/export/NewRelicExporters.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
import com.newrelic.telemetry.Attributes;
1111
import com.newrelic.telemetry.opentelemetry.export.NewRelicSpanExporter.Builder;
12+
import io.opentelemetry.api.metrics.GlobalMetricsProvider;
1213
import io.opentelemetry.sdk.OpenTelemetrySdk;
14+
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
1315
import io.opentelemetry.sdk.metrics.export.IntervalMetricReader;
1416
import io.opentelemetry.sdk.trace.export.BatchSpanProcessor;
1517

@@ -19,12 +21,19 @@ public class NewRelicExporters {
1921

2022
/**
2123
* Start up the New Relic Metric and Span exporters with the provided API key and service name.
24+
*
25+
* @param apiKey API key
26+
* @param serviceName Service name
2227
*/
2328
public static void start(String apiKey, String serviceName) {
2429
start(new Configuration(apiKey, serviceName));
2530
}
2631

27-
/** Start up the New Relic Metric and Span exporters with the provided configuration. */
32+
/**
33+
* Start up the New Relic Metric and Span exporters with the provided configuration.
34+
*
35+
* @param configuration Configuration
36+
*/
2837
public static void start(Configuration configuration) {
2938
Attributes serviceNameAttributes =
3039
new Attributes().put("service.name", configuration.serviceName);
@@ -55,7 +64,7 @@ public static void start(Configuration configuration) {
5564
.setExportIntervalMillis(configuration.collectionIntervalSeconds * 1000)
5665
.setMetricExporter(metricExporterBuilder.build())
5766
.setMetricProducers(
58-
singleton(OpenTelemetrySdk.getGlobalMeterProvider().getMetricProducer()))
67+
singleton(((SdkMeterProvider) GlobalMetricsProvider.get()).getMetricProducer()))
5968
.build();
6069
}
6170

@@ -90,6 +99,8 @@ public Configuration(String apiKey, String serviceName) {
9099
* Turn on audit logging for the exporters. Please note that this will expose all your telemetry
91100
* data to your logging system. Requires the slf4j "com.newrelic.telemetry" logger to be enabled
92101
* at DEBUG level. Defaults to being off.
102+
*
103+
* @return Configuration
93104
*/
94105
public Configuration enableAuditLogging() {
95106
this.enableAuditLogging = true;
@@ -98,6 +109,9 @@ public Configuration enableAuditLogging() {
98109

99110
/**
100111
* Set the collection interval, in seconds, for both metrics and spans. Defaults to 5 seconds.
112+
*
113+
* @param interval Interval in seconds
114+
* @return Configuration
101115
*/
102116
public Configuration collectionIntervalSeconds(int interval) {
103117
collectionIntervalSeconds = interval;

0 commit comments

Comments
 (0)