Skip to content

Commit 3dbe121

Browse files
keith-deckerzhirafovod
authored andcommitted
rename exporter to emitter.
1 parent 765758e commit 3dbe121

File tree

4 files changed

+21
-110
lines changed

4 files changed

+21
-110
lines changed

util/opentelemetry-util-genai/src/opentelemetry/util/genai/api.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from opentelemetry.trace import get_tracer
2424

2525
from .data import ChatGeneration, Error, Message
26-
from .exporters import SpanMetricEventExporter, SpanMetricExporter
26+
from .emitters import SpanMetricEmitter, SpanMetricEventEmitter
2727
from .types import LLMInvocation
2828

2929
# TODO: Get the tool version for emitting spans, use GenAI Utils for now
@@ -32,11 +32,11 @@
3232

3333
class TelemetryClient:
3434
"""
35-
High-level client managing GenAI invocation lifecycles and exporting
35+
High-level client managing GenAI invocation lifecycles and emitting
3636
them as spans, metrics, and events.
3737
"""
3838

39-
def __init__(self, exporter_type_full: bool = True, **kwargs):
39+
def __init__(self, emitter_type_full: bool = True, **kwargs):
4040
tracer_provider = kwargs.get("tracer_provider")
4141
self._tracer = get_tracer(
4242
__name__,
@@ -61,14 +61,14 @@ def __init__(self, exporter_type_full: bool = True, **kwargs):
6161
schema_url=Schemas.V1_28_0.value,
6262
)
6363

64-
self._exporter = (
65-
SpanMetricEventExporter(
64+
self._emitter = (
65+
SpanMetricEventEmitter(
6666
tracer=self._tracer,
6767
meter=self._meter,
6868
event_logger=self._event_logger,
6969
)
70-
if exporter_type_full
71-
else SpanMetricExporter(tracer=self._tracer, meter=self._meter)
70+
if emitter_type_full
71+
else SpanMetricEmitter(tracer=self._tracer, meter=self._meter)
7272
)
7373

7474
self._llm_registry: dict[UUID, LLMInvocation] = {}
@@ -89,7 +89,7 @@ def start_llm(
8989
)
9090
with self._lock:
9191
self._llm_registry[invocation.run_id] = invocation
92-
self._exporter.init(invocation)
92+
self._emitter.init(invocation)
9393

9494
def stop_llm(
9595
self,
@@ -102,7 +102,7 @@ def stop_llm(
102102
invocation.end_time = time.time()
103103
invocation.chat_generations = chat_generations
104104
invocation.attributes.update(attributes)
105-
self._exporter.export(invocation)
105+
self._emitter.emit(invocation)
106106
return invocation
107107

108108
def fail_llm(
@@ -112,7 +112,7 @@ def fail_llm(
112112
invocation = self._llm_registry.pop(run_id)
113113
invocation.end_time = time.time()
114114
invocation.attributes.update(**attributes)
115-
self._exporter.error(error, invocation)
115+
self._emitter.error(error, invocation)
116116
return invocation
117117

118118

@@ -121,12 +121,12 @@ def fail_llm(
121121

122122

123123
def get_telemetry_client(
124-
exporter_type_full: bool = True, **kwargs
124+
emitter_type_full: bool = True, **kwargs
125125
) -> TelemetryClient:
126126
global _default_client
127127
if _default_client is None:
128128
_default_client = TelemetryClient(
129-
exporter_type_full=exporter_type_full, **kwargs
129+
emitter_type_full=emitter_type_full, **kwargs
130130
)
131131
return _default_client
132132

util/opentelemetry-util-genai/src/opentelemetry/util/genai/exporters.py renamed to util/opentelemetry-util-genai/src/opentelemetry/util/genai/emitters.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,22 @@ def _get_metric_attributes(
127127
return attributes
128128

129129

130-
class BaseExporter:
130+
class BaseEmitter:
131131
"""
132-
Abstract base for exporters mapping GenAI types -> OpenTelemetry.
132+
Abstract base for emitters mapping GenAI types -> OpenTelemetry.
133133
"""
134134

135135
def init(self, invocation: LLMInvocation):
136136
raise NotImplementedError
137137

138-
def export(self, invocation: LLMInvocation):
138+
def emit(self, invocation: LLMInvocation):
139139
raise NotImplementedError
140140

141141
def error(self, error: Error, invocation: LLMInvocation):
142142
raise NotImplementedError
143143

144144

145-
class SpanMetricEventExporter(BaseExporter):
145+
class SpanMetricEventEmitter(BaseEmitter):
146146
"""
147147
Emits spans, metrics and events for a full telemetry picture.
148148
"""
@@ -202,7 +202,7 @@ def init(self, invocation: LLMInvocation):
202202
)
203203
)
204204

205-
def export(self, invocation: LLMInvocation):
205+
def emit(self, invocation: LLMInvocation):
206206
system = invocation.attributes.get("system")
207207
span = self._start_span(
208208
name=f"{system}.chat",
@@ -361,7 +361,7 @@ def error(self, error: Error, invocation: LLMInvocation):
361361
)
362362

363363

364-
class SpanMetricExporter(BaseExporter):
364+
class SpanMetricEmitter(BaseEmitter):
365365
"""
366366
Emits only spans and metrics (no events).
367367
"""
@@ -409,7 +409,7 @@ def init(self, invocation: LLMInvocation):
409409
invocation.run_id
410410
)
411411

412-
def export(self, invocation: LLMInvocation):
412+
def emit(self, invocation: LLMInvocation):
413413
system = invocation.attributes.get("system")
414414
span = self._start_span(
415415
name=f"{system}.chat",

util/opentelemetry-util-genai/src/opentelemetry/util/genai/evals.py

Lines changed: 0 additions & 89 deletions
This file was deleted.

util/opentelemetry-util-genai/src/opentelemetry/util/genai/instruments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from opentelemetry.metrics import Histogram, Meter
22
from opentelemetry.semconv._incubating.metrics import gen_ai_metrics
33

4-
# TODO: should this be in sdk or passed to the telemetry client?
4+
# TODO: should this be in utils or passed to the telemetry client?
55
_GEN_AI_CLIENT_OPERATION_DURATION_BUCKETS = [
66
0.01,
77
0.02,
@@ -19,7 +19,7 @@
1919
81.92,
2020
]
2121

22-
# TODO: should this be in sdk or passed to the telemetry client?
22+
# TODO: should this be in utils or passed to the telemetry client?
2323
_GEN_AI_CLIENT_TOKEN_USAGE_BUCKETS = [
2424
1,
2525
4,

0 commit comments

Comments
 (0)