-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Closed
Labels
api: runIssues related to the Cloud Run API.Issues related to the Cloud Run API.samplesIssues that are directly related to samples.Issues that are directly related to samples.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
GCP Cloud run does not seem to respect the ResourceAttributes of OTEL
from opentelemetry import trace
from opentelemetry.semconv.resource import ResourceAttributes
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
from opentelemetry.propagate import set_global_textmap
from opentelemetry.propagators.cloud_trace_propagator import CloudTraceFormatPropagator
API_CODE_VERSION = os.getenv('API_CODE_VERSION', '0.1')
ENV = os.getenv("ENV", "preprod")
set_global_textmap(CloudTraceFormatPropagator())
tracer_provider = TracerProvider(resource=Resource.create(attributes={
ResourceAttributes.SERVICE_VERSION: API_CODE_VERSION,
ResourceAttributes.DEPLOYMENT_ENVIRONMENT: ENV,
ResourceAttributes.SERVICE_NAME: "toto"
}))
tracer_provider.add_span_processor(BatchSpanProcessor(CloudTraceSpanExporter(project_id=TRACING_GCP_PROJECT_ID)))
trace.set_tracer_provider(tracer_provider)
FastAPIInstrumentor.instrument_app(app=app_fast_api, excluded_urls="/health,/openapi.json")running this will give span in cloud trace , but the ResourceAttributes do not appear in the filter options of cloud run
andrewmackett
Metadata
Metadata
Assignees
Labels
api: runIssues related to the Cloud Run API.Issues related to the Cloud Run API.samplesIssues that are directly related to samples.Issues that are directly related to samples.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.

