Deprecated Google Cloud integrations for OpenTelemetry
Project description
DEPRECATED
This package is deprecated. It will not receive any more updates. Please use opentelemetry-exporter-gcp-monitoring and opentelemetry-exporter-gcp-trace instead. It will not receive any more updates.
This library provides support for:
Exporting traces to Google Cloud Trace
Exporting metrics to Google Cloud Monitoring
For resource detection and GCP trace context propagation, see opentelemetry-tools-google-cloud.
Installation
pip install opentelemetry-exporter-google-cloud
Usage
Traces
from opentelemetry import trace
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
SimpleExportSpanProcessor,
)
trace.set_tracer_provider(TracerProvider())
cloud_trace_exporter = CloudTraceSpanExporter(
project_id='my-gcloud-project',
)
trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(cloud_trace_exporter)
)
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span('foo'):
print('Hello world!')
Metrics
import time
from opentelemetry import metrics
from opentelemetry.exporter.cloud_monitoring import (
CloudMonitoringMetricsExporter,
)
from opentelemetry.sdk.metrics import Counter, MeterProvider
metrics.set_meter_provider(MeterProvider())
meter = metrics.get_meter(__name__)
metrics.get_meter_provider().start_pipeline(
meter, CloudMonitoringMetricsExporter(), 5
)
requests_counter = meter.create_counter(
name="request_counter",
description="number of requests",
unit="1",
value_type=int
)
staging_labels = {"environment": "staging"}
for i in range(20):
requests_counter.add(25, staging_labels)
time.sleep(10)
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-google-cloud-0.18b1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa8d3af9ce6ba73ec66a16a58e6b2d714e9d3aebc311ab7aa748dc6cebc2f03e |
|
MD5 | 16ea536563221de86e4f860831d3fa8e |
|
BLAKE2b-256 | 4c0f86e5c5ef85ec0e2101dc8d6e96574f80d1678665185164ab8e14c5d86b8c |
Close
Hashes for opentelemetry_exporter_google_cloud-0.18b1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cc1b0fbf7b82118b8a9a48cb99a563c3b483024a8d914e9790693afdf33b27d |
|
MD5 | 0c45d0da86336474b68c7182b7804405 |
|
BLAKE2b-256 | 246a565535b0b8fbaac1f81453cb172e9a8b2dc491a172cda689ef8915de468f |