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

Async instruments don't do spatial reaggregation when attributes are dropped #4901

Open
Tracked by #21121
jack-berg opened this issue Oct 31, 2022 · 0 comments
Open
Tracked by #21121
Labels
Bug Something isn't working metrics

Comments

@jack-berg
Copy link
Member

As discussed in open-telemetry/opentelemetry-specification#2905, several languages don't do spatial reaggregation when attributes are dropped via views. Java is one of those languages.

Here's an example snippet that demonstrates the issue:

    InMemoryMetricReader reader = InMemoryMetricReader.create();
    SdkMeterProvider meterProvider =
        SdkMeterProvider.builder()
            .registerMetricReader(reader)
            .registerView(
                InstrumentSelector.builder().setName("my-instrument").build(),
                View.builder().setAttributeFilter(attributeKey -> false).build())
            .build();

    Meter myMeter = meterProvider.get("my-meter");

    LongUpDownCounterBuilder myInstrument = myMeter.upDownCounterBuilder("my-instrument");
    myInstrument.buildWithCallback(
        observable -> {
          observable.record(10, Attributes.builder().put("key", "value1").build());
          observable.record(10, Attributes.builder().put("key", "value2").build());
        });

    OpenTelemetryAssertions.assertThat(reader.collectAllMetrics())
        .satisfiesExactly(
            metricData ->
                OpenTelemetryAssertions.assertThat(metricData)
                    .hasLongSumSatisfying(
                        sum ->
                            sum.hasPointsSatisfying(
                                point ->
                                    point
                                        # .hasValue(20) // Correct behavior: should aggregate the two 10 values together
                                        .hasValue(10) // Actual behavior: takes the last reported measurement without aggregation
                                        .hasAttributes(
                                            Attributes.empty()))));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working metrics
Projects
None yet
Development

No branches or pull requests

1 participant