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

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.11.0a0.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_resourcedetector_gcp-1.11.0a0.tar.gz
Algorithm Hash digest
SHA256 915a1d6fd15daca9eedd3fc52b0f705375054f2ef140e2e7a6b4cca95a47cdb1
MD5 723ed9f55e7729cf6d5813a5db862d70
BLAKE2b-256 c15d2b3240d914b87b6dd9cd5ca2ef1ccaf1d0626b897d4c06877e22c8c10fcf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opentelemetry_resourcedetector_gcp-1.11.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d65a2a039b1d40c6f41421dbb08d5f441368275ac6de6e76a8fccd1f6acb67e
MD5 d548a08cb47582309646bb68943f07bc
BLAKE2b-256 c36c1e13fe142a7ca3dc6489167203a1209d32430cca12775e1df9c9a41c54b2

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