Skip to content

Commit

Permalink
fix: add service name to opentelemetry instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
fdupont authored and crqs committed Feb 8, 2024
1 parent dfe0df9 commit 6bd3b4b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.5.0
3.5.1
3 changes: 2 additions & 1 deletion src/pythie_serving/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.instrumentation.grpc import GrpcInstrumentorServer
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor

Expand All @@ -20,7 +21,7 @@
def initialize_opentelemetry():
otel_collector_host = str(os.environ.get("OPENTELEMETRY_COLLECTOR_HOST"))
if otel_collector_host is not None:
trace.set_tracer_provider(TracerProvider())
trace.set_tracer_provider(TracerProvider(resource=Resource(attributes={"service.name": "pythie-serving"})))
otlp_exporter = OTLPSpanExporter(endpoint=otel_collector_host, insecure=True)
trace.get_tracer_provider().add_span_processor(BatchSpanProcessor(otlp_exporter))
GrpcInstrumentorServer().instrument()
Expand Down

0 comments on commit 6bd3b4b

Please sign in to comment.