GoogleCloudPlatform / GoogleCloudPlatform/opentelemetry-operations-python
Unsupported metric data type ExponentialHistogram in opentelemetry-exporter-gcp-monitoring
- Lingua principale
- Python
- Stelle
- 83
- Fork
- 46
- Merge medio
- 11h 40m
- PR unite (30g)
- 2
Descrizione
Hello,
I am having issues exporting an opentelemetry histogram to Google Cloud with **exponential bucketing.**
I get the error "Unsupported metric data type ExponentialHistogram, ignoring it" which I believe comes from this [code](https://github.com/GoogleCloudPlatform/opentelemetry-operations-python/blob/main/opentelemetry-exporter-gcp-monitoring/src/opentelemetry/exporter/cloud_monitoring/__init__.py) line 216.
I am using the following code:
```
from opentelemetry.exporter.cloud_monitoring import (
CloudMonitoringMetricsExporter,
)
from opentelemetry.sdk.metrics import MeterProvider, Histogram
from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.metrics.view import View
import random
import time
from opentelemetry.sdk.metrics._internal.aggregation import (
ExponentialBucketHistogramAggregation,
)
project_id = "my_project_id"
meter_provider = MeterProvider(
metric_readers=[
PeriodicExportingMetricReader(
CloudMonitoringMetricsExporter(
project_id=project_id,
),
export_interval_millis=30000,
)
],
resource=Resource.create(
{
"service.name": "test-matthieu-opentelemetry",
}
),
views=[
View(
instrument_type=Histogram,
aggregation=ExponentialBucketHistogramAggregation(),
)
],
)
meter = meter_provider.get_meter("test-meter")
request_duration_seconds = meter.create_histogram("test_histogram")
while True:
value = random.random()
request_duration_seconds.record(value)
time.sleep(10)
```
with the following packages on Python 3.10.12:
opentelemetry-api==1.27.0
opentelemetry-exporter-gcp-monitoring==1.7.0a0
opentelemetry-resourcedetector-gcp==1.7.0a0
opentelemetry-sdk==1.27.0
If I remove the view part with the ExponentialBucketHistogramAggregation, the export then runs successfully but with the default explicit histogram bucketing boundaries defined [here](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#explicit-bucket-histogram-aggregation). I would like to be able to run it with the ExponentialBucketHistogramAggregation.
I have seen that is possible to do it in opentelemetry-operations-js with this example in the [README](https://github.com/GoogleCloudPlatform/opentelemetry-operations-js/blob/main/packages/opentelemetry-cloud-monitoring-exporter/README.md#enabling-exponential-histograms).
Is there something that I am missing ? Or are exponential buckets not supported in opentelemetry-operations-python (as the error seems to indicate) ?
Thanks for the help,
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia in opentelemetry-exporter-gcp-monitoring/src/opentelemetry/exporter/cloud_monitoring/__init__.py alla riga 216, dove ExponentialHistogram è indicato come non supportato. Esegui il riproduttore Python fornito e confronta il comportamento previsto con l’esempio nel README di opentelemetry-operations-js. Il lavoro è completato quando gli istogrammi esponenziali vengono esportati in Google Cloud invece di essere ignorati e il comportamento rilevante è stato verificato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- google-cloud, python
- Ambito
- cloud, observability-sre
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100