Connecting Alternate Backend to GCP Metrics/Traces
Question
In the below documentation https://logfire.pydantic.dev/docs/guides/advanced/alternative-backends/#other-environment-variables
it is mentioned if OTEL_TRACES_EXPORTER and/or OTEL_METRICS_EXPORTER is configured, it can work with alternate Backends
Can I connect the same to GCP Cloud Monitoring (Metrics & Traces)
Can you provide an Example?
@hramezani @adriangb have either of you configured this?
You'd do something like this:
import logfire
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
from opentelemetry.sdk.trace.export import BatchSpanProcessor
logfire.configure(
send_to_logfire=False,
additional_span_processors=[
BatchSpanProcessor(CloudTraceSpanExporter())
]
)
You'll need to make sure that wherever this is running has IAM permissions properly configured, or your passing in credentials, etc.
More info: https://github.com/GoogleCloudPlatform/opentelemetry-operations-python
@alexmojaki do we have a way to pass in additional metrics sinks?
Yes, logfire.configure(metrics=logfire.MetricsOptions(additional_readers=[...]))
Hi @adriangb @alexmojaki This worked, few IAM permissions were needed.
Thanks, this will help a lot in debugging our app issues
Does someone wants to document this, or can we close it? @adriangb @alexmojaki
I don't want to document it, but someone should. More generally we need some docs about processors and exporters, see e.g. https://github.com/pydantic/logfire/issues/486