Skip to content

Sum not being reset on AggreagationTempoarlity.DELTA Histograms #2532

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

Closed
pichlermarc opened this issue Mar 16, 2022 · 0 comments · Fixed by #2533
Closed

Sum not being reset on AggreagationTempoarlity.DELTA Histograms #2532

pichlermarc opened this issue Mar 16, 2022 · 0 comments · Fixed by #2533
Labels
bug Something isn't working metrics sdk Affects the SDK package.

Comments

@pichlermarc
Copy link
Member

Describe your environment

  • Python 3.8.10
  • Ubuntu 20.04
  • OTel Python Metrics SDK v0.29b0

Steps to reproduce

Here's an example that exports to the console:

from opentelemetry import _metrics
from opentelemetry.sdk._metrics import MeterProvider
from opentelemetry.sdk._metrics.export import PeriodicExportingMetricReader, ConsoleMetricExporter
from opentelemetry.sdk._metrics.point import AggregationTemporality


class DeltaConsoleMetricExporter(ConsoleMetricExporter):
    @property
    def preferred_temporality(self) -> AggregationTemporality:
        return AggregationTemporality.DELTA

if __name__ == '__main__':
    reader = PeriodicExportingMetricReader(
            export_interval_millis=3600000,
            exporter=DeltaConsoleMetricExporter())

    _metrics.set_meter_provider(MeterProvider(metric_readers=[reader]))

    meter = _metrics.get_meter("my.meter")

    my_instrument = meter.create_histogram(
        name="my.instrument",
    )

    my_instrument.record(10)
    reader.collect()
    my_instrument.record(10)
    reader.collect()
    my_instrument.record(10)
    reader.collect()

What is the expected behavior?

sum should not carry over from the last collection cycle to the next, should be 10 on every export.

What is the actual behavior?

sum carries over from the previous collection cycle to the next.

Console Output from the example above:

{"attributes": "", "description": "", "instrumentation_info": "InstrumentationInfo(my.meter, , None)", "name": "my.instrument", "resource": "BoundedAttributes({'telemetry.sdk.language': 'python', 'telemetry.sdk.name': 'opentelemetry', 'telemetry.sdk.version': '1.10.0', 'service.name': 'unknown_service'}, maxlen=None)", "unit": "", "point": {"start_time_unix_nano": 1647361426978696864, "time_unix_nano": 1647361426978710755, "bucket_counts": [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], "explicit_bounds": [0.0, 5.0, 10.0, 25.0, 50.0, 75.0, 100.0, 250.0, 500.0, 1000.0], "sum": 10, "aggregation_temporality": 1}}
{"attributes": "", "description": "", "instrumentation_info": "InstrumentationInfo(my.meter, , None)", "name": "my.instrument", "resource": "BoundedAttributes({'telemetry.sdk.language': 'python', 'telemetry.sdk.name': 'opentelemetry', 'telemetry.sdk.version': '1.10.0', 'service.name': 'unknown_service'}, maxlen=None)", "unit": "", "point": {"start_time_unix_nano": 1647361426978710756, "time_unix_nano": 1647361427004077424, "bucket_counts": [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], "explicit_bounds": [0.0, 5.0, 10.0, 25.0, 50.0, 75.0, 100.0, 250.0, 500.0, 1000.0], "sum": 20, "aggregation_temporality": 1}}
{"attributes": "", "description": "", "instrumentation_info": "InstrumentationInfo(my.meter, , None)", "name": "my.instrument", "resource": "BoundedAttributes({'telemetry.sdk.language': 'python', 'telemetry.sdk.name': 'opentelemetry', 'telemetry.sdk.version': '1.10.0', 'service.name': 'unknown_service'}, maxlen=None)", "unit": "", "point": {"start_time_unix_nano": 1647361427004077425, "time_unix_nano": 1647361427004196751, "bucket_counts": [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], "explicit_bounds": [0.0, 5.0, 10.0, 25.0, 50.0, 75.0, 100.0, 250.0, 500.0, 1000.0], "sum": 30, "aggregation_temporality": 1}}
{"attributes": "", "description": "", "instrumentation_info": "InstrumentationInfo(my.meter, , None)", "name": "my.instrument", "resource": "BoundedAttributes({'telemetry.sdk.language': 'python', 'telemetry.sdk.name': 'opentelemetry', 'telemetry.sdk.version': '1.10.0', 'service.name': 'unknown_service'}, maxlen=None)", "unit": "", "point": {"start_time_unix_nano": 1647361427004196752, "time_unix_nano": 1647361427004373526, "bucket_counts": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "explicit_bounds": [0.0, 5.0, 10.0, 25.0, 50.0, 75.0, 100.0, 250.0, 500.0, 1000.0], "sum": 30, "aggregation_temporality": 1}}

sum is kept over multiple collection cycles while bucket count is being reset.

@pichlermarc pichlermarc added the bug Something isn't working label Mar 16, 2022
@aabmass aabmass added sdk Affects the SDK package. metrics labels Mar 17, 2022
ocelotl added a commit to ocelotl/opentelemetry-python that referenced this issue Mar 18, 2022
ocelotl added a commit to ocelotl/opentelemetry-python that referenced this issue Mar 18, 2022
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 sdk Affects the SDK package.
Projects
None yet
2 participants