Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronous gauge can not send out immediately when be called. #6455

Closed
tongshushan opened this issue May 11, 2024 · 5 comments
Closed

Synchronous gauge can not send out immediately when be called. #6455

tongshushan opened this issue May 11, 2024 · 5 comments

Comments

@tongshushan
Copy link

tongshushan commented May 11, 2024

Describe the bug
Hello ,

Refer to #5506 , I find the Synchronous gauge can not be sent out immediately when called, also sent out Periodically(interaval: 1minute)

I am not sure whether it works as designed or it's a bug.

Steps to reproduce

Call rest api: /testSendSynchronizedGauge as below:

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.metrics.Meter;
import io.opentelemetry.extension.incubator.metrics.DoubleGauge;
import io.opentelemetry.extension.incubator.metrics.ExtendedDoubleGaugeBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
public class OtlpTestController {
    @Autowired
    OpenTelemetry openTelemetry;

    @GetMapping("/testSendSynchronizedGauge")
    public String testSendSynchronizedGauge() {
        Meter meter = openTelemetry.meterBuilder("instrumentation-library-name")
                .setInstrumentationVersion("1.0.0")
                .build();
        DoubleGauge gauge = ((ExtendedDoubleGaugeBuilder) meter.gaugeBuilder("my-gauge")).build();
        gauge.set(1.0);
        return "ok";
    }
}

io.opentelemetry: 1.37.0

What did you expect to see?
Expect to see the metrics immeditely in otlp exporters.

What did you see instead?
Metrics delayed.

Additional context
Full code: #6378

@tongshushan tongshushan added the Bug Something isn't working label May 11, 2024
@jkwatson
Copy link
Contributor

Not sure what problem you're seeing. A synchronous gauge recording will happen immediately, but the export will still only happen on the configured interval for export. Are you expecting the exporter to immediately send the gauge value when recorded?

Also, please be aware that a synchronous gauge is aggregated with the "last value" aggregation, so only the last one recorded will ever be sent.

@tongshushan
Copy link
Author

Hi @jkwatson

What's the difference between Synchronous gauge and Asynchronous gauge?

I am not sure whether I misunderstand it or not, I think Synchronous gauge should send out the metric data imediately(Synchronously), for example ,when call the below codes the exporter should recieve 10 numbers(1,2,3....10), but actually only received 1 number(10).

LongGauge gauge = ((ExtendedLongGaugeBuilder) meter.gaugeBuilder("my-gauge").setDescription("request duration metrics").ofLongs()).build();
for(long i=1;i<=10;i++){
            gauge.set(i);
}

@jkwatson
Copy link
Contributor

@tongshushan The "Synchronous" vs. "Asynchronous" refers to how the values for the instrument are intended to be recorded. "Asynchronous" instruments have their values recorded via an asynchronous callback, usually once per collection cycle. "Synchronous" instruments are used "synchronous" with (for example) request code. The reporting of the values is independent of the recording of them, and is handled by the exporter/aggregation configuration, not at the API level, where the distinction exists.

If this isn't clear, I recommend reading the specification documents about how these instruments are intended to be used.

Hope that helps!

@breedx-splk breedx-splk added needs author feedback Waiting for additional feedback from the author and removed Bug Something isn't working labels May 17, 2024
@jack-berg
Copy link
Member

Closing. Please re-open if you think this warrants additional discussion.

@tongshushan
Copy link
Author

@jkwatson I see, thanks.

@github-actions github-actions bot removed the needs author feedback Waiting for additional feedback from the author label May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants