Skip to content

Commit 8906ae6

Browse files
committed
fix: resolve CI failures (lint, format, typecheck, changelog)
- Add # noqa: PLC0415 for intentional in-function imports in dashscope and hermes-agent - Fix unsorted imports (I001) in loongsuite-distro - Remove unnecessary # type: ignore comments in vertexai/patch.py - Apply ruff format to all affected files - Add CHANGELOG-loongsuite.md entry for semconv changes Change-Id: Ibb440bd9e057fa82a91710db85380311d11a8c86 Co-developed-by: Qoder <noreply@qoder.com>
1 parent d99dd00 commit 8906ae6

14 files changed

Lines changed: 79 additions & 79 deletions

File tree

  • instrumentation-genai/opentelemetry-instrumentation-vertexai/src/opentelemetry/instrumentation/vertexai
  • instrumentation-loongsuite
    • loongsuite-instrumentation-claude-agent-sdk/src/opentelemetry/instrumentation/claude_agent_sdk
    • loongsuite-instrumentation-claw-eval/src/opentelemetry/instrumentation/claw_eval/internal
    • loongsuite-instrumentation-dashscope/src/opentelemetry/instrumentation/dashscope/utils
    • loongsuite-instrumentation-hermes-agent/src/opentelemetry/instrumentation/hermes_agent
    • loongsuite-instrumentation-litellm/src/opentelemetry/instrumentation/litellm
    • loongsuite-instrumentation-minisweagent/src/opentelemetry/instrumentation/minisweagent/internal
    • loongsuite-instrumentation-vita/src/opentelemetry/instrumentation/vita
  • loongsuite-distro

CHANGELOG-loongsuite.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
1212
## Unreleased
1313

14+
### Changed
15+
16+
- Adopt upstream semantic conventions for LoongSuite instrumentation packages.
17+
1418
## Version 0.5.0 (2026-05-11)
1519

1620
### Fixed

instrumentation-genai/opentelemetry-instrumentation-vertexai/src/opentelemetry/instrumentation/vertexai/patch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def handle_response(
173173
| None,
174174
) -> None:
175175
attributes = (
176-
get_server_attributes(instance.api_endpoint) # type: ignore[reportUnknownMemberType]
176+
get_server_attributes(instance.api_endpoint)
177177
| request_attributes
178178
| get_genai_response_attributes(response)
179179
)
@@ -257,7 +257,7 @@ def _with_default_instrumentation(
257257
kwargs: Any,
258258
):
259259
params = _extract_params(*args, **kwargs)
260-
api_endpoint: str = instance.api_endpoint # type: ignore[reportUnknownMemberType]
260+
api_endpoint: str = instance.api_endpoint
261261
span_attributes = {
262262
**get_genai_request_attributes(False, params),
263263
**get_server_attributes(api_endpoint),

instrumentation-loongsuite/loongsuite-instrumentation-claude-agent-sdk/src/opentelemetry/instrumentation/claude_agent_sdk/__init__.py

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,14 @@ def _instrument(self, **kwargs: Any) -> None:
102102
wrap_function_wrapper(
103103
module="claude_agent_sdk",
104104
name="ClaudeSDKClient.__init__",
105-
wrapper=lambda wrapped,
106-
instance,
107-
args,
108-
kwargs: wrap_claude_client_init(
109-
wrapped,
110-
instance,
111-
args,
112-
kwargs,
113-
handler=ClaudeAgentSDKInstrumentor._handler,
105+
wrapper=lambda wrapped, instance, args, kwargs: (
106+
wrap_claude_client_init(
107+
wrapped,
108+
instance,
109+
args,
110+
kwargs,
111+
handler=ClaudeAgentSDKInstrumentor._handler,
112+
)
114113
),
115114
)
116115
except Exception as e:
@@ -122,15 +121,14 @@ def _instrument(self, **kwargs: Any) -> None:
122121
wrap_function_wrapper(
123122
module="claude_agent_sdk",
124123
name="ClaudeSDKClient.query",
125-
wrapper=lambda wrapped,
126-
instance,
127-
args,
128-
kwargs: wrap_claude_client_query(
129-
wrapped,
130-
instance,
131-
args,
132-
kwargs,
133-
handler=ClaudeAgentSDKInstrumentor._handler,
124+
wrapper=lambda wrapped, instance, args, kwargs: (
125+
wrap_claude_client_query(
126+
wrapped,
127+
instance,
128+
args,
129+
kwargs,
130+
handler=ClaudeAgentSDKInstrumentor._handler,
131+
)
134132
),
135133
)
136134
except Exception as e:
@@ -140,15 +138,14 @@ def _instrument(self, **kwargs: Any) -> None:
140138
wrap_function_wrapper(
141139
module="claude_agent_sdk",
142140
name="ClaudeSDKClient.receive_response",
143-
wrapper=lambda wrapped,
144-
instance,
145-
args,
146-
kwargs: wrap_claude_client_receive_response(
147-
wrapped,
148-
instance,
149-
args,
150-
kwargs,
151-
handler=ClaudeAgentSDKInstrumentor._handler,
141+
wrapper=lambda wrapped, instance, args, kwargs: (
142+
wrap_claude_client_receive_response(
143+
wrapped,
144+
instance,
145+
args,
146+
kwargs,
147+
handler=ClaudeAgentSDKInstrumentor._handler,
148+
)
152149
),
153150
)
154151
except Exception as e:

instrumentation-loongsuite/loongsuite-instrumentation-claw-eval/src/opentelemetry/instrumentation/claw_eval/internal/wrappers.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
# string instead of reading it from ``gen_ai_attributes``.
6363
GEN_AI_TOOL_DEFINITIONS = "gen_ai.tool.definitions"
6464

65+
6566
def _infer_provider_name(provider: Any) -> str:
6667
"""Infer gen_ai.provider.name from the provider instance."""
6768
if provider is None:
@@ -89,7 +90,6 @@ def _infer_provider_name(provider: Any) -> str:
8990
return "openai"
9091

9192

92-
9393
# ---------------------------------------------------------------------------
9494
# ContextVars for STEP lifecycle & compact-depth tracking
9595
# ---------------------------------------------------------------------------
@@ -545,9 +545,7 @@ def __call__(self, wrapped, instance, args, kwargs):
545545
# Set gen_ai.provider.name (Required attribute)
546546
_provider_name = _infer_provider_name(provider)
547547
if _provider_name:
548-
span.set_attribute(
549-
GenAI.GEN_AI_PROVIDER_NAME, _provider_name
550-
)
548+
span.set_attribute(GenAI.GEN_AI_PROVIDER_NAME, _provider_name)
551549

552550
model_id = ""
553551
if provider is not None:

instrumentation-loongsuite/loongsuite-instrumentation-dashscope/src/opentelemetry/instrumentation/dashscope/utils/common.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ def _extract_usage(response: Any) -> tuple[Optional[int], Optional[int]]:
8888
return None, None
8989

9090

91-
def _extract_cache_tokens(response: Any) -> tuple[Optional[int], Optional[int]]:
91+
def _extract_cache_tokens(
92+
response: Any,
93+
) -> tuple[Optional[int], Optional[int]]:
9294
"""Extract cache token usage from DashScope response.
9395
9496
Args:
@@ -106,10 +108,9 @@ def _extract_cache_tokens(response: Any) -> tuple[Optional[int], Optional[int]]:
106108
return None, None
107109

108110
# DashScope may report cache tokens in various fields
109-
cache_creation = (
110-
getattr(usage, "cache_creation_input_tokens", None)
111-
or getattr(usage, "cache_creation_tokens", None)
112-
)
111+
cache_creation = getattr(
112+
usage, "cache_creation_input_tokens", None
113+
) or getattr(usage, "cache_creation_tokens", None)
113114
cache_read = (
114115
getattr(usage, "cache_read_input_tokens", None)
115116
or getattr(usage, "cache_read_tokens", None)

instrumentation-loongsuite/loongsuite-instrumentation-dashscope/src/opentelemetry/instrumentation/dashscope/utils/generation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,8 @@ def _update_invocation_from_response(
571571
invocation.output_tokens = output_tokens
572572

573573
# Extract cache token usage
574-
from ..utils.common import _extract_cache_tokens
574+
from ..utils.common import _extract_cache_tokens # noqa: PLC0415
575+
575576
cache_creation, cache_read = _extract_cache_tokens(response)
576577
if cache_creation is not None:
577578
invocation.usage_cache_creation_input_tokens = cache_creation

instrumentation-loongsuite/loongsuite-instrumentation-hermes-agent/src/opentelemetry/instrumentation/hermes_agent/helpers.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ def _extract_server_info(instance: Any) -> tuple[str | None, int | None]:
617617
return None, None
618618
base_url_str = str(base_url).rstrip("/")
619619
try:
620-
from urllib.parse import urlparse
620+
from urllib.parse import urlparse # noqa: PLC0415
621621

622622
parsed = urlparse(base_url_str)
623623
address = parsed.hostname
@@ -703,14 +703,17 @@ def update_llm_invocation_from_response(
703703
if cached and cached > 0:
704704
invocation.usage_cache_read_input_tokens = cached
705705
# Direct fields (some providers)
706-
cache_creation = (
707-
getattr(usage, "cache_creation_input_tokens", None)
708-
or getattr(usage, "cache_creation_tokens", None)
709-
)
706+
cache_creation = getattr(
707+
usage, "cache_creation_input_tokens", None
708+
) or getattr(usage, "cache_creation_tokens", None)
710709
if cache_creation and cache_creation > 0:
711710
invocation.usage_cache_creation_input_tokens = cache_creation
712711
cache_read = getattr(usage, "cache_read_input_tokens", None)
713-
if cache_read and cache_read > 0 and not invocation.usage_cache_read_input_tokens:
712+
if (
713+
cache_read
714+
and cache_read > 0
715+
and not invocation.usage_cache_read_input_tokens
716+
):
714717
invocation.usage_cache_read_input_tokens = cache_read
715718

716719
return input_tokens, output_tokens, total_tokens

instrumentation-loongsuite/loongsuite-instrumentation-litellm/src/opentelemetry/instrumentation/litellm/_wrapper.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,8 @@ def __call__(self, *args, **kwargs):
9494
callback=None,
9595
invocation=invocation,
9696
)
97-
stream_wrapper.callback = (
98-
lambda span,
99-
last_chunk,
100-
error: self._handle_stream_end_with_handler(
97+
stream_wrapper.callback = lambda span, last_chunk, error: (
98+
self._handle_stream_end_with_handler(
10199
invocation, last_chunk, error, stream_wrapper
102100
)
103101
)
@@ -240,10 +238,8 @@ async def __call__(self, *args, **kwargs):
240238
callback=None,
241239
invocation=invocation,
242240
)
243-
stream_wrapper.callback = (
244-
lambda span,
245-
last_chunk,
246-
error: self._handle_stream_end_with_handler(
241+
stream_wrapper.callback = lambda span, last_chunk, error: (
242+
self._handle_stream_end_with_handler(
247243
invocation, last_chunk, error, stream_wrapper
248244
)
249245
)

instrumentation-loongsuite/loongsuite-instrumentation-minisweagent/src/opentelemetry/instrumentation/minisweagent/internal/agent_wrappers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def __call__(
113113
han.start_entry(entry_inv, context=context_api.get_current())
114114

115115
inv = InvokeAgentInvocation(
116-
provider="minisweagent", agent_name=agent_name,
116+
provider="minisweagent",
117+
agent_name=agent_name,
117118
agent_id=agent_name,
118119
)
119120
inv.request_model = _request_model_from_agent(instance)

instrumentation-loongsuite/loongsuite-instrumentation-vita/src/opentelemetry/instrumentation/vita/patch.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,9 @@ def wrap_generate_next_message(
354354
invocation.usage_cache_read_input_tokens = cached
355355
cache_creation = usage.get("cache_creation_input_tokens")
356356
if cache_creation and cache_creation > 0:
357-
invocation.usage_cache_creation_input_tokens = cache_creation
357+
invocation.usage_cache_creation_input_tokens = (
358+
cache_creation
359+
)
358360

359361
handler.stop_invoke_agent(invocation)
360362
return result
@@ -409,7 +411,9 @@ def wrap_generate(
409411
invocation.response_model_name = model
410412

411413
# response_id
412-
resp_id = getattr(result, "id", None) or getattr(result, "response_id", None)
414+
resp_id = getattr(result, "id", None) or getattr(
415+
result, "response_id", None
416+
)
413417
if resp_id:
414418
invocation.response_id = str(resp_id)
415419

@@ -432,7 +436,9 @@ def wrap_generate(
432436
invocation.usage_cache_read_input_tokens = cached
433437
cache_creation = usage.get("cache_creation_input_tokens")
434438
if cache_creation and cache_creation > 0:
435-
invocation.usage_cache_creation_input_tokens = cache_creation
439+
invocation.usage_cache_creation_input_tokens = (
440+
cache_creation
441+
)
436442

437443
handler.stop_llm(invocation)
438444
return result

0 commit comments

Comments
 (0)