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
Close
Hashes for opentelemetry-exporter-gcp-monitoring-1.5.0a0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33fa3563a05ae2f5b7e5bf05e68333d4442ead290eb29f5f50213b6d91cd3da6 |
|
MD5 | 522eff5b27b531c76e6148159c9b1547 |
|
BLAKE2b-256 | 54895e8e154e63e2d3b5b8b2bb948a16cee549fe4942ec8648c38e7a30d2857f |
Close
Hashes for opentelemetry_exporter_gcp_monitoring-1.5.0a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7c0730f5ffef5c041e4b177f68cc421e5c774c7b5658aea9c9fa93397d06a25 |
|
MD5 | 4233e6c817ad1068513ce14a3484b582 |
|
BLAKE2b-256 | aa66dd32bf82116f4186c5d4da8e2ce4a619e6f8a58b8fab78fdb0b131e36c55 |