Skip to content

Commit

Permalink
Revert "run everything under worker_process_init"
Browse files Browse the repository at this point in the history
This reverts commit ed411d4.
  • Loading branch information
abdollahis2 authored and abdollahis2 committed Jul 5, 2024
1 parent ed411d4 commit d2ef020
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions tr_sys/tr_sys/otel_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,33 @@ def configure_opentelemetry():
jaeger_host= 'jaeger-otel-agent.sri'
jaeger_port= 6831
service_name= 'ARS'
@worker_process_init.connect(weak=False)
def init_celery_tracing(**kwargs):
resource = Resource.create({telemetery_service_name_key: service_name})
resource = Resource.create({telemetery_service_name_key: service_name})

trace.set_tracer_provider(TracerProvider(resource=resource))

trace.set_tracer_provider(TracerProvider(resource=resource))
tracer_provider = trace.get_tracer_provider()

tracer_provider = trace.get_tracer_provider()
# Configure Jaeger Exporter
jaeger_exporter = JaegerExporter(
agent_host_name=jaeger_host,
agent_port=jaeger_port,
)

# Configure Jaeger Exporter
jaeger_exporter = JaegerExporter(
agent_host_name=jaeger_host,
agent_port=jaeger_port,
)
span_processor = BatchSpanProcessor(jaeger_exporter)
tracer_provider.add_span_processor(span_processor)

span_processor = BatchSpanProcessor(jaeger_exporter)
tracer_provider.add_span_processor(span_processor)
# Optional: Console exporter for debugging
console_exporter = ConsoleSpanExporter()
tracer_provider.add_span_processor(BatchSpanProcessor(console_exporter))

# Optional: Console exporter for debugging
console_exporter = ConsoleSpanExporter()
tracer_provider.add_span_processor(BatchSpanProcessor(console_exporter))
DjangoInstrumentor().instrument()
RequestsInstrumentor().instrument()

DjangoInstrumentor().instrument()
RequestsInstrumentor().instrument()
@worker_process_init.connect(weak=False)
def init_celery_tracing(*args, **kwargs):
CeleryInstrumentor().instrument()


logging.info('Finished instrumenting ARS app for OTEL')
logging.info('Finished instrumenting ARS app for OTEL')
except Exception as e:
logging.error('OTEL instrumentation failed because: %s'%str(e))

0 comments on commit d2ef020

Please sign in to comment.