99
1010import com .newrelic .telemetry .Attributes ;
1111import com .newrelic .telemetry .opentelemetry .export .NewRelicSpanExporter .Builder ;
12+ import io .opentelemetry .api .metrics .GlobalMetricsProvider ;
1213import io .opentelemetry .sdk .OpenTelemetrySdk ;
14+ import io .opentelemetry .sdk .metrics .SdkMeterProvider ;
1315import io .opentelemetry .sdk .metrics .export .IntervalMetricReader ;
1416import 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