Skip to content

Commit

Permalink
Add global tracer provider to enable instrumentation libraries to do …
Browse files Browse the repository at this point in the history
…their work
  • Loading branch information
jp-agenta committed Sep 4, 2024
1 parent 00e7560 commit e34df9e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions agenta-cli/agenta/sdk/tracing/opentelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from agenta.sdk.utils.logging import log
from agenta.client.backend.types.create_span import CreateSpan, LlmTokens

from opentelemetry.trace import set_tracer_provider
from opentelemetry.context import Context
from opentelemetry.sdk.trace import (
Span,
Expand Down Expand Up @@ -166,6 +167,7 @@ def __init__(
project_id: Optional[str] = None,
api_key: Optional[str] = None,
experiment_id: Optional[str] = None,
set_global_tracer_provider: Optional[bool] = True,
) -> None:
# ENDPOINT
self.url = url
Expand Down Expand Up @@ -195,6 +197,7 @@ def __init__(
# num_threads=2, # inline_processor + remote_processor
# )
)

# self.tracer_provider.add_span_processor(
# TraceProcessor(
# OTLPSpanExporter(
Expand All @@ -205,6 +208,10 @@ def __init__(
# )
self.inline_processor = TraceProcessor(InlineTraceExporter(registry=self.spans))
self.tracer_provider.add_span_processor(self.inline_processor)

if set_global_tracer_provider is True:
set_tracer_provider(self.tracer_provider)

# TRACER
self.tracer = self.tracer_provider.get_tracer("ag.tracing")

Expand Down

0 comments on commit e34df9e

Please sign in to comment.