Skip to content

Commit 0e966fe

Browse files
committed
fixed conflict
1 parent 13d29b5 commit 0e966fe

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

.github/component_owners.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ components:
4040
util/opentelemetry-util-genai:
4141
- DylanRussell
4242
- keith-decker
43+
44+
instrumentation-genai/opentelemetry-instrumentation-langchain:
45+
- zhirafovod
46+
- wrisa

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class LangChainInstrumentor(BaseInstrumentor):
6060
"""
6161

6262
def __init__(
63-
self, exception_logger: Optional[Callable[[Exception], Any]] = None
63+
self,
6464
):
6565
super().__init__()
6666

@@ -76,7 +76,7 @@ def _instrument(self, **kwargs: Any):
7676
__name__,
7777
__version__,
7878
tracer_provider,
79-
schema_url=Schemas.V1_28_0.value,
79+
schema_url=Schemas.V1_30_0.value,
8080
)
8181

8282
otel_callback_handler = OpenTelemetryLangChainCallbackHandler(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def end_span(self, run_id: UUID) -> None:
9797
child_state = self.spans.get(child_id)
9898
if child_state:
9999
child_state.span.end()
100+
del self.spans[child_id]
100101
state.span.end()
101102
del self.spans[run_id]
102103

instrumentation-genai/opentelemetry-instrumentation-langchain/tests/test_span_manager.py

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55

66
from opentelemetry.instrumentation.langchain.span_manager import (
7-
SpanManager,
7+
_SpanManager,
88
_SpanState,
99
)
1010
from opentelemetry.trace import SpanKind, get_tracer
@@ -18,7 +18,7 @@ def tracer(self):
1818

1919
@pytest.fixture
2020
def handler(self, tracer):
21-
return SpanManager(tracer=tracer)
21+
return _SpanManager(tracer=tracer)
2222

2323
@pytest.mark.parametrize(
2424
"parent_run_id,parent_in_spans",
@@ -28,6 +28,7 @@ def handler(self, tracer):
2828
(uuid.uuid4(), True), # Parent in spans
2929
],
3030
)
31+
3132
def test_create_span(
3233
self, handler, tracer, parent_run_id, parent_in_spans
3334
):
@@ -42,7 +43,7 @@ def test_create_span(
4243
if parent_run_id is not None and parent_in_spans:
4344
parent_mock_span = unittest.mock.Mock(spec=Span)
4445
handler.spans[parent_run_id] = _SpanState(
45-
span=parent_mock_span, context=None
46+
span=parent_mock_span
4647
)
4748

4849
with (
@@ -52,12 +53,9 @@ def test_create_span(
5253
unittest.mock.patch(
5354
"opentelemetry.instrumentation.langchain.span_manager.set_span_in_context"
5455
) as mock_set_span_in_context,
55-
unittest.mock.patch(
56-
"opentelemetry.instrumentation.langchain.span_manager.get_current"
57-
),
5856
):
5957
# Act
60-
result = handler.create_span(
58+
result = handler._create_span(
6159
run_id, parent_run_id, span_name, kind
6260
)
6361

@@ -81,4 +79,29 @@ def test_create_span(
8179
mock_start_span.assert_called_once_with(
8280
name=span_name, kind=kind
8381
)
84-
mock_set_span_in_context.assert_not_called()
82+
mock_set_span_in_context.assert_called_once_with(mock_span)
83+
84+
85+
def test_end_span(
86+
self, handler
87+
):
88+
# Arrange
89+
run_id = uuid.uuid4()
90+
mock_span = unittest.mock.Mock(spec=Span)
91+
mock_context = unittest.mock.Mock()
92+
handler.spans[run_id] = _SpanState(span=mock_span)
93+
94+
# Add a child to verify it's removed
95+
child_run_id = uuid.uuid4()
96+
child_mock_span = unittest.mock.Mock(spec=Span)
97+
handler.spans[child_run_id] = _SpanState(span=child_mock_span)
98+
handler.spans[run_id].children.append(child_run_id)
99+
100+
# Act
101+
handler.end_span(run_id)
102+
103+
# Assert
104+
mock_span.end.assert_called_once()
105+
child_mock_span.end.assert_called_once()
106+
assert run_id not in handler.spans
107+
assert child_run_id not in handler.spans

0 commit comments

Comments
 (0)