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.12.0a0.tar.gz (18.8 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.12.0a0.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_resourcedetector_gcp-1.12.0a0.tar.gz
Algorithm Hash digest
SHA256 d5e3f78283a272eb92547e00bbeff45b7332a34ae791a70ab4eba81af9bc3baf
MD5 636ea10578147927b8b94cc39ce570bc
BLAKE2b-256 21aeb62c5e986c9c7f908a15682ea173bcfcdc00403c0c85243ccbd30eca7fc2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opentelemetry_resourcedetector_gcp-1.12.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 e803688d14e2969fe816077be81f7b034368314d485863f12ce49daba7c81919
MD5 7afcdc09ca20103fa7f1c2c41b891e76
BLAKE2b-256 df849db2999adbc41505af3e6717e8d958746778cbfc9e07ed9c670bf9d1e6db

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