Skip to content

Commit 83b071b

Browse files
committed
removed context and added issue
1 parent ffd899f commit 83b071b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

instrumentation-genai/opentelemetry-instrumentation-langchain/src/opentelemetry/instrumentation/langchain/callback_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def on_chat_model_start(
130130

131131
def on_llm_end(
132132
self,
133-
response: LLMResult, # type: ignore
133+
response: LLMResult, # type: ignore [reportUnknownParameterType]
134134
*,
135135
run_id: UUID,
136136
parent_run_id: UUID | None,

instrumentation-genai/opentelemetry-instrumentation-langchain/src/opentelemetry/instrumentation/langchain/span_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from typing import Dict, List, Optional
1717
from uuid import UUID
1818

19-
from opentelemetry.context import Context, get_current
2019
from opentelemetry.semconv._incubating.attributes import (
2120
gen_ai_attributes as GenAI,
2221
)
@@ -32,7 +31,6 @@
3231
@dataclass
3332
class _SpanState:
3433
span: Span
35-
context: Context
3634
children: List[UUID] = field(default_factory=list)
3735

3836

@@ -44,6 +42,7 @@ def __init__(
4442
self._tracer = tracer
4543

4644
# Map from run_id -> _SpanState, to keep track of spans and parent/child relationships
45+
# TODO: Use weak references or a TTL cache to avoid memory leaks in long-running processes. See #3735
4746
self.spans: Dict[UUID, _SpanState] = {}
4847

4948
def _create_span(
@@ -64,8 +63,9 @@ def _create_span(
6463
else:
6564
# top-level or missing parent
6665
span = self._tracer.start_span(name=span_name, kind=kind)
66+
set_span_in_context(span)
6767

68-
span_state = _SpanState(span=span, context=get_current())
68+
span_state = _SpanState(span=span)
6969
self.spans[run_id] = span_state
7070

7171
return span

0 commit comments

Comments
 (0)