logfire icon indicating copy to clipboard operation
logfire copied to clipboard

Connecting Alternate Backend to GCP Metrics/Traces

Open sandeep540 opened this issue 1 year ago • 6 comments

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?

sandeep540 avatar Dec 06 '24 13:12 sandeep540

@hramezani @adriangb have either of you configured this?

alexmojaki avatar Dec 06 '24 16:12 alexmojaki

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?

adriangb avatar Dec 06 '24 16:12 adriangb

Yes, logfire.configure(metrics=logfire.MetricsOptions(additional_readers=[...]))

alexmojaki avatar Dec 06 '24 16:12 alexmojaki

Hi @adriangb @alexmojaki This worked, few IAM permissions were needed.

Thanks, this will help a lot in debugging our app issues

sandeep540 avatar Dec 17 '24 13:12 sandeep540

Does someone wants to document this, or can we close it? @adriangb @alexmojaki

Kludex avatar Dec 24 '24 08:12 Kludex

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

alexmojaki avatar Dec 24 '24 08:12 alexmojaki