Skip to content

Commit dbc935d

Browse files
authored
Merge pull request #1161 from guardrails-ai/unified-service-tagging
add unified service tags to hub telemetry tracer
2 parents b765e4d + c936167 commit dbc935d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

guardrails/utils/hub_telemetry_utils.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# Imports
22
import logging
33
from typing import Optional
4-
54
from guardrails.settings import settings
5+
from guardrails.version import GUARDRAILS_VERSION
66
from opentelemetry.exporter.otlp.proto.http.trace_exporter import ( # HTTP Exporter
77
OTLPSpanExporter,
88
)
9-
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
9+
from opentelemetry.sdk.resources import (
10+
SERVICE_NAME,
11+
Resource,
12+
SERVICE_VERSION,
13+
DEPLOYMENT_ENVIRONMENT,
14+
)
1015
from opentelemetry.sdk.trace import TracerProvider
1116
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, BatchSpanProcessor
1217
from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
@@ -68,7 +73,12 @@ def initialize_tracer(
6873

6974
# Create a resource
7075
# Service name is required for most backends
71-
self._resource = Resource(attributes={SERVICE_NAME: self._service_name})
76+
attributes = {
77+
SERVICE_NAME: self._service_name,
78+
SERVICE_VERSION: GUARDRAILS_VERSION,
79+
DEPLOYMENT_ENVIRONMENT: "production",
80+
}
81+
self._resource = Resource(attributes=attributes)
7282

7383
# Create a tracer provider and a processor
7484
self._tracer_provider = TracerProvider(resource=self._resource)

0 commit comments

Comments
 (0)