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.6.0a0.tar.gz
.
File metadata
- Download URL: opentelemetry-exporter-gcp-monitoring-1.6.0a0.tar.gz
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d29059de11c0133b670914da82ee14f06299da896fbfbceea61161b464316a58 |
|
MD5 | 75e7943a4fece3cd79880f0c1d791540 |
|
BLAKE2b-256 | 685e4d2b827407e47f7fb44834e0afaa9b95cb5a2670320b7f8440c48a94aa47 |
Provenance
File details
Details for the file opentelemetry_exporter_gcp_monitoring-1.6.0a0-py3-none-any.whl
.
File metadata
- Download URL: opentelemetry_exporter_gcp_monitoring-1.6.0a0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1b8bdaa4ccee8160d195362ae6d9a3099975d357441cbb1c29046cc63673077 |
|
MD5 | 13796c360a0749e53ae8fb5c610ba0b8 |
|
BLAKE2b-256 | 07a99f36862e19b6e726876d0c3f8b9b0457583846620914297b2ea11097872f |