Google Cloud resource detector for OpenTelemetry
Project description
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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opentelemetry_resourcedetector_gcp-1.11.0a0.tar.gz.
File metadata
- Download URL: opentelemetry_resourcedetector_gcp-1.11.0a0.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
915a1d6fd15daca9eedd3fc52b0f705375054f2ef140e2e7a6b4cca95a47cdb1
|
|
| MD5 |
723ed9f55e7729cf6d5813a5db862d70
|
|
| BLAKE2b-256 |
c15d2b3240d914b87b6dd9cd5ca2ef1ccaf1d0626b897d4c06877e22c8c10fcf
|
File details
Details for the file opentelemetry_resourcedetector_gcp-1.11.0a0-py3-none-any.whl.
File metadata
- Download URL: opentelemetry_resourcedetector_gcp-1.11.0a0-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d65a2a039b1d40c6f41421dbb08d5f441368275ac6de6e76a8fccd1f6acb67e
|
|
| MD5 |
d548a08cb47582309646bb68943f07bc
|
|
| BLAKE2b-256 |
c36c1e13fe142a7ca3dc6489167203a1209d32430cca12775e1df9c9a41c54b2
|