GoogleCloudPlatform / GoogleCloudPlatform/opentelemetry-operations-python

Running on multiple AppEngine instances

Open
#219 7 comments 0 reactions 0 assignees View on GitHub
priority: p3 question
Dominant language
Python
Stars
83
Forks
46
Avg merge
11h 40m
Merged PRs (30d)
2

Description

I've been setting up OTel metrics with Google Cloud Monitoring for our Django app running on AppEngine.

I used code that looked like this

```python
metrics_exporter = CloudMonitoringMetricsExporter(
project_id=GOOGLE_CLOUD_PROJECT, add_unique_identifier=True
)
metric_reader = PeriodicExportingMetricReader(
exporter=metrics_exporter, export_interval_millis=5000
)

resource = Resource.create(
{
"service.name": env("GAE_SERVICE", default="cx-api"),
"service.namespace": "Our Platform",
"service.instance.id": env("GAE_INSTANCE", default="local"),
"service.version": env("GAE_VERSION", default="local"),
}
)
tracer_provider = TracerProvider(resource=resource)
tracer_provider.add_span_processor(BatchSpanProcessor(trace_exporter))
trace.set_tracer_provider(tracer_provider)

metrics.set_meter_provider(
MeterProvider(
metric_readers=[metric_reader],
# As GCP only allows writing to a timeseries once per second we need to make sure every instance has a different
# series by setting a unique instance id
resource=resource,
)
)
```

I thought that by using a unique instance ID I would get around the
`One or more TimeSeries could not be written: One or more points were written more frequently than the maximum sampling period configured for the metric`
issue. But it seems I really need to use `add_unique_identifier=True`. While I understand this for multithreaded applications or multiple exporters for the same resource, I don't understand it if the resource is already unique.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.