lmnr 0.6.2__tar.gz → 0.6.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lmnr-0.6.2 → lmnr-0.6.4}/PKG-INFO +1 -1
- {lmnr-0.6.2 → lmnr-0.6.4}/pyproject.toml +1 -1
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/cli.py +18 -11
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/__init__.py +6 -7
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/decorators/__init__.py +23 -8
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/__init__.py +2 -2
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/config.py +4 -4
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/opentelemetry/instrumentation/google_genai/utils.py +19 -19
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/tracing/__init__.py +6 -7
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/tracing/_instrument_initializers.py +32 -33
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/tracing/context_properties.py +2 -3
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/tracing/exporter.py +4 -5
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/tracing/instruments.py +5 -6
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/tracing/processor.py +6 -7
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/browser/utils.py +4 -3
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/client/asynchronous/async_client.py +26 -11
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/client/asynchronous/resources/__init__.py +2 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/client/asynchronous/resources/agent.py +89 -91
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/client/asynchronous/resources/evals.py +8 -8
- lmnr-0.6.4/src/lmnr/sdk/client/asynchronous/resources/tags.py +89 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/client/synchronous/resources/__init__.py +2 -1
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/client/synchronous/resources/agent.py +91 -91
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/client/synchronous/resources/evals.py +8 -8
- lmnr-0.6.4/src/lmnr/sdk/client/synchronous/resources/tags.py +89 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/client/synchronous/sync_client.py +28 -13
- lmnr-0.6.4/src/lmnr/sdk/decorators.py +103 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/eval_control.py +1 -1
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/evaluations.py +75 -52
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/laminar.py +76 -58
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/types.py +47 -37
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/utils.py +3 -3
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/version.py +1 -1
- lmnr-0.6.2/src/lmnr/sdk/decorators.py +0 -87
- {lmnr-0.6.2 → lmnr-0.6.4}/LICENSE +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/README.md +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/__init__.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/.flake8 +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/tracing/attributes.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/tracing/tracer.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/utils/__init__.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/utils/json_encoder.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/opentelemetry_lib/utils/package_check.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/py.typed +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/__init__.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/browser/__init__.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/browser/browser_use_otel.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/browser/patchright_otel.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/browser/playwright_otel.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/browser/pw_utils.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/browser/rrweb/rrweb.umd.min.cjs +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/client/asynchronous/resources/base.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/client/asynchronous/resources/browser_events.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/client/synchronous/resources/base.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/client/synchronous/resources/browser_events.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/datasets.py +0 -0
- {lmnr-0.6.2 → lmnr-0.6.4}/src/lmnr/sdk/log.py +0 -0
@@ -4,11 +4,10 @@ import importlib.util
|
|
4
4
|
import os
|
5
5
|
import re
|
6
6
|
import sys
|
7
|
-
from typing import Optional
|
8
7
|
|
9
8
|
from lmnr.sdk.evaluations import Evaluation
|
10
9
|
|
11
|
-
from .sdk.eval_control import PREPARE_ONLY,
|
10
|
+
from .sdk.eval_control import PREPARE_ONLY, EVALUATION_INSTANCES
|
12
11
|
from .sdk.log import get_default_logger
|
13
12
|
|
14
13
|
LOG = get_default_logger(__name__)
|
@@ -38,10 +37,10 @@ async def run_evaluation(args):
|
|
38
37
|
else:
|
39
38
|
files = [args.file]
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
prep_token = PREPARE_ONLY.set(True)
|
41
|
+
try:
|
42
|
+
for file in files:
|
43
|
+
LOG.info(f"Running evaluation from {file}")
|
45
44
|
file = os.path.abspath(file)
|
46
45
|
name = "user_module" + file
|
47
46
|
|
@@ -55,16 +54,24 @@ async def run_evaluation(args):
|
|
55
54
|
sys.modules[name] = mod
|
56
55
|
|
57
56
|
spec.loader.exec_module(mod)
|
58
|
-
|
59
|
-
if
|
57
|
+
evaluations: list[Evaluation] | None = EVALUATION_INSTANCES.get()
|
58
|
+
if evaluations is None:
|
60
59
|
LOG.warning("Evaluation instance not found")
|
61
60
|
if args.fail_on_error:
|
62
61
|
return
|
63
62
|
continue
|
64
63
|
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
LOG.info(f"Loaded {len(evaluations)} evaluations from {file}")
|
65
|
+
|
66
|
+
for evaluation in evaluations:
|
67
|
+
try:
|
68
|
+
await evaluation.run()
|
69
|
+
except Exception as e:
|
70
|
+
LOG.error(f"Error running evaluation: {e}")
|
71
|
+
if args.fail_on_error:
|
72
|
+
raise
|
73
|
+
finally:
|
74
|
+
PREPARE_ONLY.reset(prep_token)
|
68
75
|
|
69
76
|
|
70
77
|
def cli():
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import logging
|
2
2
|
import sys
|
3
3
|
|
4
|
-
from typing import Optional, Set
|
5
4
|
from opentelemetry.sdk.trace.export import SpanExporter
|
6
5
|
from opentelemetry.sdk.resources import SERVICE_NAME
|
7
6
|
|
@@ -16,17 +15,17 @@ class TracerManager:
|
|
16
15
|
|
17
16
|
@staticmethod
|
18
17
|
def init(
|
19
|
-
app_name:
|
18
|
+
app_name: str | None = sys.argv[0],
|
20
19
|
disable_batch=False,
|
21
|
-
exporter:
|
20
|
+
exporter: SpanExporter | None = None,
|
22
21
|
resource_attributes: dict = {},
|
23
|
-
instruments:
|
24
|
-
block_instruments:
|
22
|
+
instruments: set[Instruments] | None = None,
|
23
|
+
block_instruments: set[Instruments] | None = None,
|
25
24
|
base_url: str = "https://api.lmnr.ai",
|
26
25
|
port: int = 8443,
|
27
26
|
http_port: int = 443,
|
28
|
-
project_api_key:
|
29
|
-
max_export_batch_size:
|
27
|
+
project_api_key: str | None = None,
|
28
|
+
max_export_batch_size: int | None = None,
|
30
29
|
force_http: bool = False,
|
31
30
|
timeout_seconds: int = 30,
|
32
31
|
set_global_tracer_provider: bool = True,
|
@@ -3,12 +3,16 @@ import json
|
|
3
3
|
import logging
|
4
4
|
import pydantic
|
5
5
|
import types
|
6
|
-
from typing import Any, Literal
|
6
|
+
from typing import Any, Literal
|
7
7
|
|
8
8
|
from opentelemetry import trace
|
9
9
|
from opentelemetry import context as context_api
|
10
10
|
from opentelemetry.trace import Span
|
11
11
|
|
12
|
+
from lmnr.opentelemetry_lib.tracing.context_properties import (
|
13
|
+
remove_association_properties,
|
14
|
+
update_association_properties,
|
15
|
+
)
|
12
16
|
from lmnr.sdk.utils import get_input_from_func_args, is_method
|
13
17
|
from lmnr.opentelemetry_lib import MAX_MANUAL_SPAN_PAYLOAD_SIZE
|
14
18
|
from lmnr.opentelemetry_lib.tracing.tracer import get_tracer
|
@@ -37,11 +41,12 @@ def json_dumps(data: dict) -> str:
|
|
37
41
|
|
38
42
|
|
39
43
|
def entity_method(
|
40
|
-
name:
|
44
|
+
name: str | None = None,
|
41
45
|
ignore_input: bool = False,
|
42
|
-
ignore_inputs:
|
46
|
+
ignore_inputs: list[str] | None = None,
|
43
47
|
ignore_output: bool = False,
|
44
|
-
span_type:
|
48
|
+
span_type: Literal["DEFAULT", "LLM", "TOOL"] = "DEFAULT",
|
49
|
+
association_properties: dict[str, Any] | None = None,
|
45
50
|
):
|
46
51
|
def decorate(fn):
|
47
52
|
@wraps(fn)
|
@@ -51,6 +56,9 @@ def entity_method(
|
|
51
56
|
|
52
57
|
span_name = name or fn.__name__
|
53
58
|
|
59
|
+
if association_properties is not None:
|
60
|
+
update_association_properties(association_properties)
|
61
|
+
|
54
62
|
with get_tracer() as tracer:
|
55
63
|
span = tracer.start_span(span_name, attributes={SPAN_TYPE: span_type})
|
56
64
|
|
@@ -111,7 +119,8 @@ def entity_method(
|
|
111
119
|
|
112
120
|
span.end()
|
113
121
|
context_api.detach(ctx_token)
|
114
|
-
|
122
|
+
if association_properties is not None:
|
123
|
+
remove_association_properties(association_properties)
|
115
124
|
return res
|
116
125
|
|
117
126
|
return wrap
|
@@ -121,11 +130,12 @@ def entity_method(
|
|
121
130
|
|
122
131
|
# Async Decorators
|
123
132
|
def aentity_method(
|
124
|
-
name:
|
133
|
+
name: str | None = None,
|
125
134
|
ignore_input: bool = False,
|
126
|
-
ignore_inputs:
|
135
|
+
ignore_inputs: list[str] | None = None,
|
127
136
|
ignore_output: bool = False,
|
128
|
-
span_type:
|
137
|
+
span_type: Literal["DEFAULT", "LLM", "TOOL"] = "DEFAULT",
|
138
|
+
association_properties: dict[str, Any] | None = None,
|
129
139
|
):
|
130
140
|
def decorate(fn):
|
131
141
|
@wraps(fn)
|
@@ -135,6 +145,9 @@ def aentity_method(
|
|
135
145
|
|
136
146
|
span_name = name or fn.__name__
|
137
147
|
|
148
|
+
if association_properties is not None:
|
149
|
+
update_association_properties(association_properties)
|
150
|
+
|
138
151
|
with get_tracer() as tracer:
|
139
152
|
span = tracer.start_span(span_name, attributes={SPAN_TYPE: span_type})
|
140
153
|
|
@@ -187,6 +200,8 @@ def aentity_method(
|
|
187
200
|
pass
|
188
201
|
|
189
202
|
span.end()
|
203
|
+
if association_properties is not None:
|
204
|
+
remove_association_properties(association_properties)
|
190
205
|
context_api.detach(ctx_token)
|
191
206
|
|
192
207
|
return res
|
@@ -3,7 +3,7 @@
|
|
3
3
|
from collections import defaultdict
|
4
4
|
import logging
|
5
5
|
import os
|
6
|
-
from typing import AsyncGenerator, Callable, Collection, Generator
|
6
|
+
from typing import AsyncGenerator, Callable, Collection, Generator
|
7
7
|
|
8
8
|
from google.genai import types
|
9
9
|
|
@@ -152,7 +152,7 @@ def _set_request_attributes(span, args, kwargs):
|
|
152
152
|
|
153
153
|
if should_send_prompts():
|
154
154
|
i = 0
|
155
|
-
system_instruction:
|
155
|
+
system_instruction: types.ContentUnion | None = config_dict.get(
|
156
156
|
"system_instruction"
|
157
157
|
)
|
158
158
|
if system_instruction:
|
@@ -1,9 +1,9 @@
|
|
1
|
-
from typing import Callable, Coroutine
|
1
|
+
from typing import Callable, Coroutine
|
2
2
|
|
3
3
|
|
4
4
|
class Config:
|
5
5
|
exception_logger = None
|
6
|
-
upload_base64_image:
|
7
|
-
Callable[[str, str, str, str], Coroutine[None, None, str]]
|
8
|
-
|
6
|
+
upload_base64_image: (
|
7
|
+
Callable[[str, str, str, str], Coroutine[None, None, str]] | None
|
8
|
+
) = None
|
9
9
|
convert_image_to_openai_format: bool = True
|
@@ -9,7 +9,7 @@ from google.genai import types
|
|
9
9
|
from google.genai._common import BaseModel
|
10
10
|
import pydantic
|
11
11
|
from opentelemetry.trace import Span
|
12
|
-
from typing import Any
|
12
|
+
from typing import Any
|
13
13
|
|
14
14
|
|
15
15
|
def set_span_attribute(span: Span, name: str, value: str):
|
@@ -44,7 +44,7 @@ def dont_throw(func):
|
|
44
44
|
return wrapper
|
45
45
|
|
46
46
|
|
47
|
-
def to_dict(obj:
|
47
|
+
def to_dict(obj: BaseModel | pydantic.BaseModel | dict) -> dict[str, Any]:
|
48
48
|
try:
|
49
49
|
if isinstance(obj, BaseModel):
|
50
50
|
return obj.model_dump()
|
@@ -59,11 +59,11 @@ def to_dict(obj: Union[BaseModel, pydantic.BaseModel, dict]) -> dict[str, Any]:
|
|
59
59
|
|
60
60
|
|
61
61
|
def process_content_union(
|
62
|
-
content:
|
63
|
-
trace_id:
|
64
|
-
span_id:
|
62
|
+
content: types.ContentUnion | types.ContentUnionDict,
|
63
|
+
trace_id: str | None = None,
|
64
|
+
span_id: str | None = None,
|
65
65
|
message_index: int = 0,
|
66
|
-
) ->
|
66
|
+
) -> str | None:
|
67
67
|
parts = _process_content_union(content, trace_id, span_id, message_index)
|
68
68
|
if parts is None:
|
69
69
|
return None
|
@@ -83,11 +83,11 @@ def process_content_union(
|
|
83
83
|
|
84
84
|
|
85
85
|
def _process_content_union(
|
86
|
-
content:
|
87
|
-
trace_id:
|
88
|
-
span_id:
|
86
|
+
content: types.ContentUnion | types.ContentUnionDict,
|
87
|
+
trace_id: str | None = None,
|
88
|
+
span_id: str | None = None,
|
89
89
|
message_index: int = 0,
|
90
|
-
) ->
|
90
|
+
) -> str | list[str] | None:
|
91
91
|
if isinstance(content, types.Content):
|
92
92
|
parts = to_dict(content).get("parts", [])
|
93
93
|
return [_process_part(part) for part in parts]
|
@@ -111,12 +111,12 @@ def _process_content_union(
|
|
111
111
|
|
112
112
|
|
113
113
|
def _process_part_union(
|
114
|
-
content:
|
115
|
-
trace_id:
|
116
|
-
span_id:
|
114
|
+
content: types.PartDict | types.File | types.Part | str,
|
115
|
+
trace_id: str | None = None,
|
116
|
+
span_id: str | None = None,
|
117
117
|
message_index: int = 0,
|
118
118
|
content_index: int = 0,
|
119
|
-
) ->
|
119
|
+
) -> str | None:
|
120
120
|
if isinstance(content, str):
|
121
121
|
return content
|
122
122
|
elif isinstance(content, types.File):
|
@@ -135,11 +135,11 @@ def _process_part_union(
|
|
135
135
|
|
136
136
|
def _process_part(
|
137
137
|
content: types.Part,
|
138
|
-
trace_id:
|
139
|
-
span_id:
|
138
|
+
trace_id: str | None = None,
|
139
|
+
span_id: str | None = None,
|
140
140
|
message_index: int = 0,
|
141
141
|
content_index: int = 0,
|
142
|
-
) ->
|
142
|
+
) -> str | None:
|
143
143
|
part_dict = to_dict(content)
|
144
144
|
if part_dict.get("text") is not None:
|
145
145
|
return part_dict.get("text")
|
@@ -157,8 +157,8 @@ def _process_part(
|
|
157
157
|
|
158
158
|
|
159
159
|
def role_from_content_union(
|
160
|
-
content:
|
161
|
-
) ->
|
160
|
+
content: types.ContentUnion | types.ContentUnionDict,
|
161
|
+
) -> str | None:
|
162
162
|
if isinstance(content, types.Content):
|
163
163
|
return to_dict(content).get("role")
|
164
164
|
elif isinstance(content, list) and len(content) > 0:
|
@@ -15,7 +15,6 @@ from opentelemetry.instrumentation.threading import ThreadingInstrumentor
|
|
15
15
|
from opentelemetry.sdk.resources import Resource
|
16
16
|
from opentelemetry.sdk.trace import TracerProvider, SpanProcessor
|
17
17
|
from opentelemetry.sdk.trace.export import SpanExporter
|
18
|
-
from typing import Optional, Set
|
19
18
|
|
20
19
|
module_logger = logging.getLogger(__name__)
|
21
20
|
console_log_handler = logging.StreamHandler()
|
@@ -31,7 +30,7 @@ MAX_EVENTS_OR_ATTRIBUTES_PER_SPAN = 5000
|
|
31
30
|
class TracerWrapper(object):
|
32
31
|
resource_attributes: dict = {}
|
33
32
|
enable_content_tracing: bool = True
|
34
|
-
__tracer_provider:
|
33
|
+
__tracer_provider: TracerProvider | None = None
|
35
34
|
__logger: logging.Logger
|
36
35
|
__client: LaminarClient
|
37
36
|
__async_client: AsyncLaminarClient
|
@@ -41,14 +40,14 @@ class TracerWrapper(object):
|
|
41
40
|
def __new__(
|
42
41
|
cls,
|
43
42
|
disable_batch=False,
|
44
|
-
exporter:
|
45
|
-
instruments:
|
46
|
-
block_instruments:
|
43
|
+
exporter: SpanExporter | None = None,
|
44
|
+
instruments: set[Instruments] | None = None,
|
45
|
+
block_instruments: set[Instruments] | None = None,
|
47
46
|
base_url: str = "https://api.lmnr.ai",
|
48
47
|
port: int = 8443,
|
49
48
|
http_port: int = 443,
|
50
|
-
project_api_key:
|
51
|
-
max_export_batch_size:
|
49
|
+
project_api_key: str | None = None,
|
50
|
+
max_export_batch_size: int | None = None,
|
52
51
|
force_http: bool = False,
|
53
52
|
timeout_seconds: int = 10,
|
54
53
|
set_global_tracer_provider: bool = True,
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import abc
|
2
2
|
|
3
|
-
from typing import Optional
|
4
3
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
5
4
|
|
6
5
|
from lmnr.opentelemetry_lib.utils.package_check import is_package_installed
|
@@ -8,12 +7,12 @@ from lmnr.opentelemetry_lib.utils.package_check import is_package_installed
|
|
8
7
|
|
9
8
|
class InstrumentorInitializer(abc.ABC):
|
10
9
|
@abc.abstractmethod
|
11
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
10
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
12
11
|
pass
|
13
12
|
|
14
13
|
|
15
14
|
class AlephAlphaInstrumentorInitializer(InstrumentorInitializer):
|
16
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
15
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
17
16
|
if not is_package_installed("aleph_alpha_client"):
|
18
17
|
return None
|
19
18
|
if not is_package_installed("opentelemetry-instrumentation-alephalpha"):
|
@@ -25,7 +24,7 @@ class AlephAlphaInstrumentorInitializer(InstrumentorInitializer):
|
|
25
24
|
|
26
25
|
|
27
26
|
class AnthropicInstrumentorInitializer(InstrumentorInitializer):
|
28
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
27
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
29
28
|
if not is_package_installed("anthropic"):
|
30
29
|
return None
|
31
30
|
if not is_package_installed("opentelemetry-instrumentation-anthropic"):
|
@@ -39,7 +38,7 @@ class AnthropicInstrumentorInitializer(InstrumentorInitializer):
|
|
39
38
|
|
40
39
|
|
41
40
|
class BedrockInstrumentorInitializer(InstrumentorInitializer):
|
42
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
41
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
43
42
|
if not is_package_installed("boto3"):
|
44
43
|
return None
|
45
44
|
if not is_package_installed("opentelemetry-instrumentation-bedrock"):
|
@@ -51,7 +50,7 @@ class BedrockInstrumentorInitializer(InstrumentorInitializer):
|
|
51
50
|
|
52
51
|
|
53
52
|
class BrowserUseInstrumentorInitializer(InstrumentorInitializer):
|
54
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
53
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
55
54
|
if not is_package_installed("browser-use"):
|
56
55
|
return None
|
57
56
|
|
@@ -61,7 +60,7 @@ class BrowserUseInstrumentorInitializer(InstrumentorInitializer):
|
|
61
60
|
|
62
61
|
|
63
62
|
class ChromaInstrumentorInitializer(InstrumentorInitializer):
|
64
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
63
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
65
64
|
if not is_package_installed("chromadb"):
|
66
65
|
return None
|
67
66
|
if not is_package_installed("opentelemetry-instrumentation-chromadb"):
|
@@ -73,7 +72,7 @@ class ChromaInstrumentorInitializer(InstrumentorInitializer):
|
|
73
72
|
|
74
73
|
|
75
74
|
class CohereInstrumentorInitializer(InstrumentorInitializer):
|
76
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
75
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
77
76
|
if not is_package_installed("cohere"):
|
78
77
|
return None
|
79
78
|
if not is_package_installed("opentelemetry-instrumentation-cohere"):
|
@@ -85,7 +84,7 @@ class CohereInstrumentorInitializer(InstrumentorInitializer):
|
|
85
84
|
|
86
85
|
|
87
86
|
class CrewAIInstrumentorInitializer(InstrumentorInitializer):
|
88
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
87
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
89
88
|
if not is_package_installed("crewai"):
|
90
89
|
return None
|
91
90
|
if not is_package_installed("opentelemetry-instrumentation-crewai"):
|
@@ -97,7 +96,7 @@ class CrewAIInstrumentorInitializer(InstrumentorInitializer):
|
|
97
96
|
|
98
97
|
|
99
98
|
class GoogleGenerativeAIInstrumentorInitializer(InstrumentorInitializer):
|
100
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
99
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
101
100
|
if not is_package_installed("google-generativeai"):
|
102
101
|
return None
|
103
102
|
if not is_package_installed(
|
@@ -113,7 +112,7 @@ class GoogleGenerativeAIInstrumentorInitializer(InstrumentorInitializer):
|
|
113
112
|
|
114
113
|
|
115
114
|
class GoogleGenAIInstrumentorInitializer(InstrumentorInitializer):
|
116
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
115
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
117
116
|
if not is_package_installed("google-genai"):
|
118
117
|
return None
|
119
118
|
|
@@ -125,7 +124,7 @@ class GoogleGenAIInstrumentorInitializer(InstrumentorInitializer):
|
|
125
124
|
|
126
125
|
|
127
126
|
class GroqInstrumentorInitializer(InstrumentorInitializer):
|
128
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
127
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
129
128
|
if not is_package_installed("groq"):
|
130
129
|
return None
|
131
130
|
if not is_package_installed("opentelemetry-instrumentation-groq"):
|
@@ -137,7 +136,7 @@ class GroqInstrumentorInitializer(InstrumentorInitializer):
|
|
137
136
|
|
138
137
|
|
139
138
|
class HaystackInstrumentorInitializer(InstrumentorInitializer):
|
140
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
139
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
141
140
|
if not is_package_installed("haystack"):
|
142
141
|
return None
|
143
142
|
if not is_package_installed("opentelemetry-instrumentation-haystack"):
|
@@ -149,7 +148,7 @@ class HaystackInstrumentorInitializer(InstrumentorInitializer):
|
|
149
148
|
|
150
149
|
|
151
150
|
class LanceDBInstrumentorInitializer(InstrumentorInitializer):
|
152
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
151
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
153
152
|
if not is_package_installed("lancedb"):
|
154
153
|
return None
|
155
154
|
if not is_package_installed("opentelemetry-instrumentation-lancedb"):
|
@@ -161,7 +160,7 @@ class LanceDBInstrumentorInitializer(InstrumentorInitializer):
|
|
161
160
|
|
162
161
|
|
163
162
|
class LangchainInstrumentorInitializer(InstrumentorInitializer):
|
164
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
163
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
165
164
|
if not is_package_installed("langchain"):
|
166
165
|
return None
|
167
166
|
if not is_package_installed("opentelemetry-instrumentation-langchain"):
|
@@ -173,7 +172,7 @@ class LangchainInstrumentorInitializer(InstrumentorInitializer):
|
|
173
172
|
|
174
173
|
|
175
174
|
class LlamaIndexInstrumentorInitializer(InstrumentorInitializer):
|
176
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
175
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
177
176
|
if not (
|
178
177
|
is_package_installed("llama-index") or is_package_installed("llama_index")
|
179
178
|
):
|
@@ -187,7 +186,7 @@ class LlamaIndexInstrumentorInitializer(InstrumentorInitializer):
|
|
187
186
|
|
188
187
|
|
189
188
|
class MarqoInstrumentorInitializer(InstrumentorInitializer):
|
190
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
189
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
191
190
|
if not is_package_installed("marqo"):
|
192
191
|
return None
|
193
192
|
if not is_package_installed("opentelemetry-instrumentation-marqo"):
|
@@ -199,7 +198,7 @@ class MarqoInstrumentorInitializer(InstrumentorInitializer):
|
|
199
198
|
|
200
199
|
|
201
200
|
class MCPInstrumentorInitializer(InstrumentorInitializer):
|
202
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
201
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
203
202
|
if not is_package_installed("mcp"):
|
204
203
|
return None
|
205
204
|
if not is_package_installed("opentelemetry-instrumentation-mcp"):
|
@@ -211,7 +210,7 @@ class MCPInstrumentorInitializer(InstrumentorInitializer):
|
|
211
210
|
|
212
211
|
|
213
212
|
class MilvusInstrumentorInitializer(InstrumentorInitializer):
|
214
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
213
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
215
214
|
if not is_package_installed("pymilvus"):
|
216
215
|
return None
|
217
216
|
if not is_package_installed("opentelemetry-instrumentation-milvus"):
|
@@ -223,7 +222,7 @@ class MilvusInstrumentorInitializer(InstrumentorInitializer):
|
|
223
222
|
|
224
223
|
|
225
224
|
class MistralInstrumentorInitializer(InstrumentorInitializer):
|
226
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
225
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
227
226
|
if not is_package_installed("mistralai"):
|
228
227
|
return None
|
229
228
|
if not is_package_installed("opentelemetry-instrumentation-mistralai"):
|
@@ -235,7 +234,7 @@ class MistralInstrumentorInitializer(InstrumentorInitializer):
|
|
235
234
|
|
236
235
|
|
237
236
|
class OllamaInstrumentorInitializer(InstrumentorInitializer):
|
238
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
237
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
239
238
|
if not is_package_installed("ollama"):
|
240
239
|
return None
|
241
240
|
if not is_package_installed("opentelemetry-instrumentation-ollama"):
|
@@ -247,7 +246,7 @@ class OllamaInstrumentorInitializer(InstrumentorInitializer):
|
|
247
246
|
|
248
247
|
|
249
248
|
class OpenAIInstrumentorInitializer(InstrumentorInitializer):
|
250
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
249
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
251
250
|
if not is_package_installed("openai"):
|
252
251
|
return None
|
253
252
|
if not is_package_installed("opentelemetry-instrumentation-openai"):
|
@@ -266,7 +265,7 @@ class OpenAIInstrumentorInitializer(InstrumentorInitializer):
|
|
266
265
|
class PatchrightInstrumentorInitializer(InstrumentorInitializer):
|
267
266
|
def init_instrumentor(
|
268
267
|
self, client, async_client, *args, **kwargs
|
269
|
-
) ->
|
268
|
+
) -> BaseInstrumentor | None:
|
270
269
|
if not is_package_installed("patchright"):
|
271
270
|
return None
|
272
271
|
|
@@ -276,7 +275,7 @@ class PatchrightInstrumentorInitializer(InstrumentorInitializer):
|
|
276
275
|
|
277
276
|
|
278
277
|
class PineconeInstrumentorInitializer(InstrumentorInitializer):
|
279
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
278
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
280
279
|
if not is_package_installed("pinecone"):
|
281
280
|
return None
|
282
281
|
if not is_package_installed("opentelemetry-instrumentation-pinecone"):
|
@@ -290,7 +289,7 @@ class PineconeInstrumentorInitializer(InstrumentorInitializer):
|
|
290
289
|
class PlaywrightInstrumentorInitializer(InstrumentorInitializer):
|
291
290
|
def init_instrumentor(
|
292
291
|
self, client, async_client, *args, **kwargs
|
293
|
-
) ->
|
292
|
+
) -> BaseInstrumentor | None:
|
294
293
|
if not is_package_installed("playwright"):
|
295
294
|
return None
|
296
295
|
|
@@ -300,7 +299,7 @@ class PlaywrightInstrumentorInitializer(InstrumentorInitializer):
|
|
300
299
|
|
301
300
|
|
302
301
|
class QdrantInstrumentorInitializer(InstrumentorInitializer):
|
303
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
302
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
304
303
|
if not is_package_installed("qdrant_client"):
|
305
304
|
return None
|
306
305
|
if not is_package_installed("opentelemetry-instrumentation-qdrant"):
|
@@ -312,7 +311,7 @@ class QdrantInstrumentorInitializer(InstrumentorInitializer):
|
|
312
311
|
|
313
312
|
|
314
313
|
class ReplicateInstrumentorInitializer(InstrumentorInitializer):
|
315
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
314
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
316
315
|
if not is_package_installed("replicate"):
|
317
316
|
return None
|
318
317
|
if not is_package_installed("opentelemetry-instrumentation-replicate"):
|
@@ -324,7 +323,7 @@ class ReplicateInstrumentorInitializer(InstrumentorInitializer):
|
|
324
323
|
|
325
324
|
|
326
325
|
class SageMakerInstrumentorInitializer(InstrumentorInitializer):
|
327
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
326
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
328
327
|
if not is_package_installed("boto3"):
|
329
328
|
return None
|
330
329
|
if not is_package_installed("opentelemetry-instrumentation-sagemaker"):
|
@@ -336,7 +335,7 @@ class SageMakerInstrumentorInitializer(InstrumentorInitializer):
|
|
336
335
|
|
337
336
|
|
338
337
|
class TogetherInstrumentorInitializer(InstrumentorInitializer):
|
339
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
338
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
340
339
|
if not is_package_installed("together"):
|
341
340
|
return None
|
342
341
|
if not is_package_installed("opentelemetry-instrumentation-together"):
|
@@ -348,7 +347,7 @@ class TogetherInstrumentorInitializer(InstrumentorInitializer):
|
|
348
347
|
|
349
348
|
|
350
349
|
class TransformersInstrumentorInitializer(InstrumentorInitializer):
|
351
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
350
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
352
351
|
if not is_package_installed("transformers"):
|
353
352
|
return None
|
354
353
|
if not is_package_installed("opentelemetry-instrumentation-transformers"):
|
@@ -360,7 +359,7 @@ class TransformersInstrumentorInitializer(InstrumentorInitializer):
|
|
360
359
|
|
361
360
|
|
362
361
|
class VertexAIInstrumentorInitializer(InstrumentorInitializer):
|
363
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
362
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
364
363
|
if not is_package_installed("vertexai"):
|
365
364
|
return None
|
366
365
|
if not is_package_installed("opentelemetry-instrumentation-vertexai"):
|
@@ -372,7 +371,7 @@ class VertexAIInstrumentorInitializer(InstrumentorInitializer):
|
|
372
371
|
|
373
372
|
|
374
373
|
class WatsonxInstrumentorInitializer(InstrumentorInitializer):
|
375
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
374
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
376
375
|
if not (
|
377
376
|
is_package_installed("ibm-watsonx-ai")
|
378
377
|
or is_package_installed("ibm-watson-machine-learning")
|
@@ -387,7 +386,7 @@ class WatsonxInstrumentorInitializer(InstrumentorInitializer):
|
|
387
386
|
|
388
387
|
|
389
388
|
class WeaviateInstrumentorInitializer(InstrumentorInitializer):
|
390
|
-
def init_instrumentor(self, *args, **kwargs) ->
|
389
|
+
def init_instrumentor(self, *args, **kwargs) -> BaseInstrumentor | None:
|
391
390
|
if not is_package_installed("weaviate"):
|
392
391
|
return None
|
393
392
|
if not is_package_installed("opentelemetry-instrumentation-weaviate"):
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import copy
|
2
|
-
from typing import Optional
|
3
2
|
|
4
3
|
from lmnr.opentelemetry_lib.tracing.attributes import (
|
5
4
|
ASSOCIATION_PROPERTIES,
|
@@ -18,14 +17,14 @@ def set_association_properties(properties: dict) -> None:
|
|
18
17
|
_set_association_properties_attributes(span, properties)
|
19
18
|
|
20
19
|
|
21
|
-
def get_association_properties(context:
|
20
|
+
def get_association_properties(context: Context | None = None) -> dict:
|
22
21
|
return get_value("association_properties", context) or {}
|
23
22
|
|
24
23
|
|
25
24
|
def update_association_properties(
|
26
25
|
properties: dict,
|
27
26
|
set_on_current_span: bool = True,
|
28
|
-
context:
|
27
|
+
context: Context | None = None,
|
29
28
|
) -> None:
|
30
29
|
"""Only adds or updates properties that are not already present"""
|
31
30
|
association_properties = get_value("association_properties", context) or {}
|