cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Looking to upgrade from Dynatrace Managed to SaaS? See how

Unable to end counters to Dynatrace via OTLP

prabalr
Visitor

am using an Open Telemtery JAVA SDK to publish some metrics an OTEL sink like Dynatrace. I am sending gauges, updown counters etc. to dynatrace and see that UpDown Counters are successuflly pushed, but the counters are not. Could you kindly help me understand where I could be going wrong?

The code that I am using OTLP SDK Meter Provider

    @Bean
    public SdkMeterProvider sdkMeterProvider(){
        return SdkMeterProvider.builder()
                .registerMetricReader(
                        PeriodicMetricReader.builder(
                            OtlpHttpMetricExporter.builder()
                                .setEndpoint(otlpApiUrlPrefix+"/v2/otlp/v1/metrics")
                                .addHeader("Authorization", "Api-Token "+otlpApiToken).build())
                            .setInterval(15, TimeUnit.SECONDS)  /** determines the frequency of publishing metrics **/
                        .build())
                .build();
    }

Initializing Updown Counter with callback (This works successfully)

        meter
                .upDownCounterBuilder("otlp.demo.updown.counter.with.callback")
                .setDescription("Demo updown counter with callback")
                .setUnit("boxes")
                .buildWithCallback(result -> result.record(currentvalue, attributes));

Initializing Counter with Callback

      meter
                .counterBuilder("otlp.demo.counter.with.callback")
                .setDescription("Counter with callback")
                .setUnit("count")
                .buildWithCallback(result -> result.record(currentvalue, attributes));

This does not get transmitted to the downstream OTEL Sink (Dyantrace)

Initializing Counter without Callback

        longCounterWithoutCallback = meter
                .counterBuilder("otlp.demo.counter.without.callback")
                .setDescription("Counter without callback")
                .setUnit("count")
                .build();

I am incrementing this counter as follows:

    /** Random increment/ decrement of the counter. Does not control the frequency of metrics export **/
    @Scheduled(cron = "${otlp.metrics.cron}")
    public void processCounter(){
        currentvalue = currentvalue + (-5L + (long) (Math.random() * (20L)));
        logger.info("Successfully modified counter value {}", currentvalue);
        longCounterWithoutCallback.add(1L); // Only increment the counter
    }

I am trying to use this as an example https://github.com/open-telemetry/opentelemetry-java-examples/blob/main/metrics/src/main/java/io/ope...

 
0 REPLIES 0

Featured Posts