Google Cloud Monitoring exporter for OpenTelemetry
Project description
This library provides support for exporting metrics to Google Cloud Monitoring.
For resource detection and GCP trace context propagation, see opentelemetry-tools-google-cloud. For the Google Cloud Trace exporter, see opentelemetry-exporter-gcp-trace.
Installation
pip install opentelemetry-exporter-gcp-monitoring
Usage
import time
from opentelemetry import metrics
from opentelemetry.exporter.cloud_monitoring import (
CloudMonitoringMetricsExporter,
)
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader
from opentelemetry.sdk.resources import Resource
metrics.set_meter_provider(
MeterProvider(
metric_readers=[
PeriodicExportingMetricReader(
CloudMonitoringMetricsExporter(), export_interval_millis=5000
)
],
resource=Resource.create(
{
"service.name": "basic_metrics",
"service.namespace": "examples",
"service.instance.id": "instance123",
}
),
)
)
meter = metrics.get_meter(__name__)
# Creates metric workload.googleapis.com/request_counter with monitored resource generic_task
requests_counter = meter.create_counter(
name="request_counter",
description="number of requests",
unit="1",
)
staging_labels = {"environment": "staging"}
for i in range(20):
requests_counter.add(25, staging_labels)
time.sleep(5)
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file opentelemetry_exporter_gcp_monitoring-1.7.0a0.tar.gz
.
File metadata
- Download URL: opentelemetry_exporter_gcp_monitoring-1.7.0a0.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3a3bab8e78f953070a583468d9c1855b61f9d0c5f39b4f34b9b8fd671863c55 |
|
MD5 | 118fa640fa9310a9db49b3c7a1623848 |
|
BLAKE2b-256 | 6430961c17b38cde8b0aa69fed9c4a3c69ce9d7bf341294b6fad0e751d37fd28 |
File details
Details for the file opentelemetry_exporter_gcp_monitoring-1.7.0a0-py3-none-any.whl
.
File metadata
- Download URL: opentelemetry_exporter_gcp_monitoring-1.7.0a0-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 494848ecd0e476d20d81b504a79c2df03c3c6f97b2bd42bd739f942976f08bf2 |
|
MD5 | 026af884dacd48ebd3ebdbd80373d8fb |
|
BLAKE2b-256 | 4ee6a5ac64fbd402decb3e35f4547e41d11fe0965b6f651dff38c0edf8226b1f |