Skip to content

Multiple system metrics return negative values when using DELTA temporality. #2861

@bjrara

Description

@bjrara

Describe your environment

OS: CentOS
Python version: 3.9.16
Package version: OTEL 1.25.0

What happened?

The following metrics are found with negative values when configuring to export using DELTA temporality.

  • system.network.connections
  • process.runtime.cpython.gc_count
  • process.runtime.cpython.memory
  • process.runtime.cpython.thread_count
  • process.open_file_descriptor.count

Steps to Reproduce

temporality_dict: Dict[type, AggregationTemporality] = {}
for typ in [
    Counter,
    UpDownCounter,
    ObservableCounter,
    ObservableCounter,
    ObservableUpDownCounter,
    ObservableGauge,
    Histogram,
]:
    temporality_dict[typ] = AggregationTemporality.DELTA

set_meter_provider(MeterProvider([PeriodicExportingMetricReader(ConsoleMetricExporter(preferred_temporality=temporality_dict))], resource=resource))
SystemMetricsInstrumentor().instrument()

Expected Result

Metrics generated with non-negative value

Actual Result

Metrics generated with negative value

Additional context

Sep 11 03:35:10: Descriptor:
Sep 11 03:35:10:      -> Name: process.runtime.cpython.memory
Sep 11 03:35:10:      -> Description: Runtime cpython memory
Sep 11 03:35:10:      -> Unit: bytes
Sep 11 03:35:10:      -> DataType: Sum
Sep 11 03:35:10:      -> IsMonotonic: false
Sep 11 03:35:10:      -> AggregationTemporality: Delta
Sep 11 03:35:10: NumberDataPoints #0
Sep 11 03:35:10: Data point attributes:
Sep 11 03:35:10:      -> type: Str(rss)
Sep 11 03:35:10: StartTimestamp: 2024-09-11 03:34:09.999252322 +0000 UTC
Sep 11 03:35:10: Timestamp: 2024-09-11 03:35:10.010880332 +0000 UTC
Sep 11 03:35:10: Value: -1081344
Sep 11 03:35:10: NumberDataPoints #1
Sep 11 03:35:10: Data point attributes:
Sep 11 03:35:10:      -> type: Str(vms)
Sep 11 03:35:10: StartTimestamp: 2024-09-11 03:34:09.999252322 +0000 UTC
Sep 11 03:35:10: Timestamp: 2024-09-11 03:35:10.010880332 +0000 UTC
Sep 11 03:35:10: Value: -1048576

Would you like to implement a fix?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions