Skip to main content

Google Cloud resource detector for OpenTelemetry

Project description

https://badge.fury.io/py/opentelemetry-resourcedetector-gcp.svg Documentation Status

This library provides support for detecting GCP resources like GCE, GKE, etc.

To get started with instrumentation in Google Cloud, see Generate traces and metrics with Python.

To learn more about instrumentation and observability, including opinionated recommendations for Google Cloud Observability, visit Instrumentation and observability.

Installation

pip install opentelemetry-resourcedetector-gcp

Usage

from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry import trace
from opentelemetry.sdk.resources import SERVICE_INSTANCE_ID, Resource

# This will use the GooglecloudResourceDetector under the covers.
resource = Resource.create(
    attributes={
        # Use the PID as the service.instance.id to avoid duplicate timeseries
        # from different Gunicorn worker processes.
        SERVICE_INSTANCE_ID: f"worker-{os.getpid()}",
    }
)
traceProvider = TracerProvider(resource=resource)
processor = BatchSpanProcessor(OTLPSpanExporter())
traceProvider.add_span_processor(processor)
trace.set_tracer_provider(traceProvider)

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opentelemetry_resourcedetector_gcp-1.10.0a0.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file opentelemetry_resourcedetector_gcp-1.10.0a0.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_resourcedetector_gcp-1.10.0a0.tar.gz
Algorithm Hash digest
SHA256 89b1adfdc7cb66b314da7cae78e1084ec3b64580f2d0532395ad4e079b4ae3f9
MD5 4b84bc5d0f6e9b54da13fbb48fb3821c
BLAKE2b-256 e0ed46daeac6d5c24d93a8b7bf58cccfbd190a6b9fe9a4db27e77bf5ef7b0f60

See more details on using hashes here.

File details

Details for the file opentelemetry_resourcedetector_gcp-1.10.0a0-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_resourcedetector_gcp-1.10.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 942319cad3244c2e05b67df1d89dcdb7f482e5a2239231340722ad642de848a9
MD5 3a4140c47c79b3b8b009267b8631021c
BLAKE2b-256 5238bbcb219e822299e87daf8d9df28743c946e2ef04d24f19d26a61cfd28734

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page