django instrumentation error #4039
-
I'm trying to get trace data from django app, I'm getting error in getting the trace data. Kindly help solving this issue. Error:- Transient error StatusCode.UNAVAILABLE encountered while exporting traces, retrying in 1s. code:- from opentelemetry.sdk.resources import SERVICE_NAME, Resource from opentelemetry import trace Service name is required for most backendsresource = Resource(attributes={ otlp_exporter = OTLPSpanExporter( traceProvider = TracerProvider(resource=resource) collector config:- receivers: traces: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Try something like this: from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
resource = Resource(attributes={SERVICE_NAME: "DCC-DJANGO-OTEL"})
otlp_exporter = OTLPSpanExporter(endpoint="http://10.1.150.74:4318/v1/traces")
trace_provider = TracerProvider(resource=resource)
processor = BatchSpanProcessor(otlp_exporter)
trace_provider .add_span_processor(processor)
trace.set_tracer_provider(trace_provider ) Try these steps and see if the issue is resolved! :) |
Beta Was this translation helpful? Give feedback.
Change the endpoint in your Django app to
"http://10.1.150.74:4318/v1/traces"
to match the collector's configuration.Confirm that the Django application can reach the OpenTelemetry Collector at
10.1.150.74:4318
.Look for errors or warnings in the collector logs that might indicate issues.
Ensure all collector exporters are correctly set up and functioning.
Restart both your Django application and the OpenTelemetry Collector after making changes.
Try something like this: