Skip to content

Commit ce70afd

Browse files
authored
[chore] Fix failure of github CI (#62)
2 parents da210dc + 884322a commit ce70afd

File tree

95 files changed

+5922
-3312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+5922
-3312
lines changed

.github/workflows/generate_workflows_lib/src/generate_workflows_lib/__init__.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,20 @@ def generate_misc_workflow(
235235
workflow_directory_path,
236236
)
237237

238+
238239
# LoongSuite Extension
239240
def get_loongsuite_tox_envs(additional_config_path: Path) -> list:
240241
if not additional_config_path or not additional_config_path.exists():
241242
return []
242-
243+
243244
additional_tox_ini = ToxIni(additional_config_path)
244245
additional_conf = State(get_options(), []).conf
245246
additional_section = next(additional_tox_ini.sections())
246247
additional_config_set = CoreConfigSet(
247-
additional_conf, additional_section, additional_config_path.parent, additional_config_path
248+
additional_conf,
249+
additional_section,
250+
additional_config_path.parent,
251+
additional_config_path,
248252
)
249253
(
250254
additional_config_set.loaders.extend(
@@ -265,17 +269,14 @@ def generate_extension_test_workflow(
265269
tox_ini_path: Path,
266270
workflow_directory_path: Path,
267271
additional_config_path: Path,
268-
*operating_systems
272+
*operating_systems,
269273
) -> None:
270274
loongsuite_envs = get_loongsuite_tox_envs(additional_config_path)
271275
if not loongsuite_envs:
272276
return
273-
277+
274278
_generate_workflow_with_template(
275-
get_test_job_datas(
276-
loongsuite_envs,
277-
list(operating_systems)
278-
),
279+
get_test_job_datas(loongsuite_envs, list(operating_systems)),
279280
"loongsuite_test",
280281
"test",
281282
workflow_directory_path,
@@ -290,7 +291,7 @@ def generate_extension_lint_workflow(
290291
loongsuite_envs = get_loongsuite_tox_envs(additional_config_path)
291292
if not loongsuite_envs:
292293
return
293-
294+
294295
_generate_workflow_with_template(
295296
get_lint_job_datas(loongsuite_envs),
296297
"loongsuite_lint",
@@ -307,7 +308,7 @@ def generate_extension_misc_workflow(
307308
loongsuite_envs = get_loongsuite_tox_envs(additional_config_path)
308309
if not loongsuite_envs:
309310
return
310-
311+
311312
_generate_workflow_with_template(
312313
get_misc_job_datas(loongsuite_envs),
313314
"loongsuite_misc",
@@ -317,7 +318,11 @@ def generate_extension_misc_workflow(
317318

318319

319320
def _generate_workflow_with_template(
320-
job_datas: list, name: str, template_name: str, workflow_directory_path: Path, max_jobs=250
321+
job_datas: list,
322+
name: str,
323+
template_name: str,
324+
workflow_directory_path: Path,
325+
max_jobs=250,
321326
):
322327
# Github seems to limit the amount of jobs in a workflow file, that is why
323328
# they are split in groups of 250 per workflow file.

.github/workflows/generate_workflows_loongsuite.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,20 @@
88

99
tox_ini_path = Path(__file__).parent.parent.parent.joinpath("tox.ini")
1010
# loongsuite instrumentation modules
11-
tox_loongsuite_ini_path = Path(__file__).parent.parent.parent.joinpath("tox-loongsuite.ini")
11+
tox_loongsuite_ini_path = Path(__file__).parent.parent.parent.joinpath(
12+
"tox-loongsuite.ini"
13+
)
1214
workflows_directory_path = Path(__file__).parent
1315

14-
generate_extension_test_workflow(tox_ini_path, workflows_directory_path, tox_loongsuite_ini_path, "ubuntu-latest")
15-
generate_extension_lint_workflow(tox_ini_path, workflows_directory_path, tox_loongsuite_ini_path)
16-
generate_extension_misc_workflow(tox_ini_path, workflows_directory_path, tox_loongsuite_ini_path)
16+
generate_extension_test_workflow(
17+
tox_ini_path,
18+
workflows_directory_path,
19+
tox_loongsuite_ini_path,
20+
"ubuntu-latest",
21+
)
22+
generate_extension_lint_workflow(
23+
tox_ini_path, workflows_directory_path, tox_loongsuite_ini_path
24+
)
25+
generate_extension_misc_workflow(
26+
tox_ini_path, workflows_directory_path, tox_loongsuite_ini_path
27+
)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Loongsuite Python Agent is a key component of LoongSuite, Alibaba's unified obse
66

77
LoongSuite includes the following key components:
88
* [LoongCollector](https://github.com/alibaba/loongcollector): universal node agent, which prodivdes log collection, prometheus metric collection, and network and security collection capabilities based on eBPF.
9-
* [LoongSuite Python Agent](https://github.com/alibaba/loongsuite-python-agent): a process agent providing instrumentaion for python applications.
9+
* [LoongSuite Python Agent](https://github.com/alibaba/loongsuite-python-agent): a process agent providing instrumentation for python applications.
1010
* [LoongSuite Go Agent](https://github.com/alibaba/loongsuite-go-agent): a process agent for golang with compile time instrumentation.
1111
* [LoongSuite Java Agent](https://github.com/alibaba/loongsuite-java-agent): a process agent for Java applications.
1212
* Other upcoming language agent.
@@ -179,7 +179,7 @@ global:
179179
StructureType: v2
180180
inputs:
181181
- Type: service_otlp
182-
Protocals:
182+
Protocols:
183183
GRPC:
184184
Endpoint: 0.0.0.0:6666
185185
flushers:
@@ -234,6 +234,6 @@ our [DingTalk group](https://qr.dingtalk.com/action/joingroup?code=v1,k1,mexukXI
234234
|----|----|
235235
| <img src="docs/_assets/img/loongsuite-go-sig-dingtalk.png" height="150"> | <img src="docs/_assets/img/loongsuite-java-sig-dingtalk.jpg" height="150"> |
236236

237-
## Resoures
237+
## Resources
238238
* AgentScope: https://github.com/modelscope/agentscope
239239
* Observability Community: https://observability.cn
Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# -*- coding: utf-8 -*-
2-
from typing import Any, Collection, Callable, Optional
3-
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
2+
from typing import Any, Collection
3+
44
from opentelemetry.instrumentation.agentscope.package import _instruments
55
from opentelemetry.instrumentation.agentscope.utils import is_agentscope_v1
6-
from typing_extensions import Coroutine
6+
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
77

88
__all__ = ["AgentScopeInstrumentor"]
99

10-
class AgentScopeInstrumentor(BaseInstrumentor): # type: ignore
1110

12-
def __init__(self,):
11+
class AgentScopeInstrumentor(BaseInstrumentor): # type: ignore
12+
def __init__(
13+
self,
14+
):
1315
self._meter = None
1416

1517
def instrumentation_dependencies(self) -> Collection[str]:
@@ -18,18 +20,28 @@ def instrumentation_dependencies(self) -> Collection[str]:
1820
def _instrument(self, **kwargs: Any) -> None:
1921
"""Enable AgentScope instrumentation."""
2022
if is_agentscope_v1():
21-
from opentelemetry.instrumentation.agentscope.v1 import AgentScopeV1Instrumentor
23+
from opentelemetry.instrumentation.agentscope.v1 import (
24+
AgentScopeV1Instrumentor,
25+
)
26+
2227
AgentScopeV1Instrumentor().instrument(**kwargs)
2328
else:
24-
from opentelemetry.instrumentation.agentscope.v0 import AgentScopeV0Instrumentor
29+
from opentelemetry.instrumentation.agentscope.v0 import (
30+
AgentScopeV0Instrumentor,
31+
)
32+
2533
AgentScopeV0Instrumentor().instrument(**kwargs)
2634

2735
def _uninstrument(self, **kwargs: Any) -> None:
28-
2936
if is_agentscope_v1():
30-
from opentelemetry.instrumentation.agentscope.v1 import AgentScopeV1Instrumentor
37+
from opentelemetry.instrumentation.agentscope.v1 import (
38+
AgentScopeV1Instrumentor,
39+
)
40+
3141
AgentScopeV1Instrumentor().uninstrument(**kwargs)
3242
else:
33-
from opentelemetry.instrumentation.agentscope.v0 import AgentScopeV0Instrumentor
34-
AgentScopeV0Instrumentor().uninstrument(**kwargs)
43+
from opentelemetry.instrumentation.agentscope.v0 import (
44+
AgentScopeV0Instrumentor,
45+
)
3546

47+
AgentScopeV0Instrumentor().uninstrument(**kwargs)

instrumentation-loongsuite/loongsuite-instrumentation-agentscope/src/opentelemetry/instrumentation/agentscope/shared/__init__.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,41 @@
77
and common attribute definitions.
88
"""
99

10-
from .constants import *
11-
from .telemetry_options import GenAITelemetryOptions, get_telemetry_options, set_telemetry_options
12-
from .attributes import *
10+
from .attributes import (
11+
AgentRequestAttributes,
12+
CommonAttributes,
13+
EmbeddingRequestAttributes,
14+
GenAiSpanKind,
15+
LLMRequestAttributes,
16+
LLMResponseAttributes,
17+
ToolRequestAttributes,
18+
)
19+
from .constants import (
20+
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT,
21+
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT_MAX_LENGTH,
22+
OTEL_INSTRUMENTATION_GENAI_MESSAGE_STRATEGY,
23+
)
24+
from .telemetry_options import (
25+
GenAITelemetryOptions,
26+
get_telemetry_options,
27+
set_telemetry_options,
28+
)
1329

1430
__all__ = [
1531
# Constants
1632
"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT",
17-
"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT_MAX_LENGTH",
33+
"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT_MAX_LENGTH",
1834
"OTEL_INSTRUMENTATION_GENAI_MESSAGE_STRATEGY",
1935
# Telemetry options
2036
"GenAITelemetryOptions",
2137
"get_telemetry_options",
2238
"set_telemetry_options",
2339
# Attributes
2440
"LLMRequestAttributes",
25-
"LLMResponseAttributes",
41+
"LLMResponseAttributes",
2642
"EmbeddingRequestAttributes",
2743
"AgentRequestAttributes",
28-
"ToolRequestAttributes",
44+
"ToolRequestAttributes",
2945
# Enums
3046
"GenAiSpanKind",
3147
# Attribute constants

instrumentation-loongsuite/loongsuite-instrumentation-agentscope/src/opentelemetry/instrumentation/agentscope/shared/attributes.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
from abc import ABC
1010
from dataclasses import dataclass, fields
1111
from typing import Dict, List, Optional
12+
13+
from agentscope import _config
14+
1215
from opentelemetry.semconv._incubating.attributes import (
1316
gen_ai_attributes as GenAIAttributes,
1417
)
1518
from opentelemetry.util.types import AttributeValue
19+
1620
from .constants import (
1721
CommonAttributes,
1822
GenAiSpanKind,
1923
)
20-
from agentscope import _config
2124

2225

2326
class ASBaseAttributes(ABC):
@@ -45,12 +48,14 @@ def get_span_attributes(self) -> Dict[str, AttributeValue]:
4548

4649
return attributes
4750

51+
4852
@dataclass
4953
class LLMRequestAttributes(ASBaseAttributes):
5054
"""LLM 请求属性类
51-
55+
5256
用于存储和管理 LLM 请求相关的 GenAI 语义约定属性。
5357
"""
58+
5459
SPAN_KIND = GenAiSpanKind.LLM.value
5560

5661
provider_name: Optional[str] = None
@@ -73,9 +78,10 @@ class LLMRequestAttributes(ASBaseAttributes):
7378
@dataclass
7479
class LLMResponseAttributes(ASBaseAttributes):
7580
"""LLM 响应属性类
76-
81+
7782
用于存储和管理 LLM 响应相关的 GenAI 语义约定属性。
7883
"""
84+
7985
response_id: Optional[str] = None
8086
response_model: Optional[str] = None
8187
output_type: Optional[str] = None
@@ -87,9 +93,10 @@ class LLMResponseAttributes(ASBaseAttributes):
8793
@dataclass
8894
class EmbeddingRequestAttributes(ASBaseAttributes):
8995
"""Embedding 请求属性类
90-
96+
9197
用于存储和管理 Embedding 请求相关的 GenAI 语义约定属性。
9298
"""
99+
93100
SPAN_KIND = GenAiSpanKind.EMBEDDING.value
94101

95102
provider_name: Optional[str] = None
@@ -102,9 +109,10 @@ class EmbeddingRequestAttributes(ASBaseAttributes):
102109
@dataclass
103110
class AgentRequestAttributes(ASBaseAttributes):
104111
"""Agent 请求属性类
105-
112+
106113
用于存储和管理 Agent 请求相关的 GenAI 语义约定属性。
107114
"""
115+
108116
SPAN_KIND = GenAiSpanKind.AGENT.value
109117

110118
agent_id: Optional[str] = None
@@ -120,9 +128,10 @@ class AgentRequestAttributes(ASBaseAttributes):
120128
@dataclass
121129
class ToolRequestAttributes(ASBaseAttributes):
122130
"""Tool 请求属性类
123-
131+
124132
用于存储和管理 Tool 请求相关的 GenAI 语义约定属性。
125133
"""
134+
126135
SPAN_KIND = GenAiSpanKind.TOOL.value
127136

128137
tool_call_id: Optional[str] = None
@@ -148,25 +157,21 @@ class ToolRequestAttributes(ASBaseAttributes):
148157
"request_stop_sequences": GenAIAttributes.GEN_AI_REQUEST_STOP_SEQUENCES,
149158
"system_instructions": GenAIAttributes.GEN_AI_SYSTEM_INSTRUCTIONS,
150159
"input_messages": GenAIAttributes.GEN_AI_INPUT_MESSAGES,
151-
"request_tool_definitions": CommonAttributes.GEN_AI_REQUEST_TOOL_DEFINITIONS, # agentscope semconv
152-
160+
"request_tool_definitions": CommonAttributes.GEN_AI_REQUEST_TOOL_DEFINITIONS, # agentscope semconv
153161
"response_id": GenAIAttributes.GEN_AI_RESPONSE_ID,
154162
"response_model": GenAIAttributes.GEN_AI_RESPONSE_MODEL,
155163
"output_type": GenAIAttributes.GEN_AI_OUTPUT_TYPE,
156164
"response_finish_reasons": GenAIAttributes.GEN_AI_RESPONSE_FINISH_REASONS,
157165
"usage_input_tokens": GenAIAttributes.GEN_AI_USAGE_INPUT_TOKENS,
158166
"usage_output_tokens": GenAIAttributes.GEN_AI_USAGE_OUTPUT_TOKENS,
159-
160167
"request_encoding_formats": GenAIAttributes.GEN_AI_REQUEST_ENCODING_FORMATS,
161-
162168
"agent_id": GenAIAttributes.GEN_AI_AGENT_ID,
163169
"agent_name": GenAIAttributes.GEN_AI_AGENT_NAME,
164170
"agent_description": GenAIAttributes.GEN_AI_AGENT_DESCRIPTION,
165171
"conversation_id": GenAIAttributes.GEN_AI_CONVERSATION_ID,
166-
167172
"tool_call_id": GenAIAttributes.GEN_AI_TOOL_CALL_ID,
168173
"tool_name": GenAIAttributes.GEN_AI_TOOL_NAME,
169174
"tool_description": GenAIAttributes.GEN_AI_TOOL_DESCRIPTION,
170175
"tool_type": GenAIAttributes.GEN_AI_TOOL_TYPE,
171-
"tool_call_arguments": CommonAttributes.GEN_AI_TOOL_CALL_ARGUMENTS, # agentscope semconv
176+
"tool_call_arguments": CommonAttributes.GEN_AI_TOOL_CALL_ARGUMENTS, # agentscope semconv
172177
}

instrumentation-loongsuite/loongsuite-instrumentation-agentscope/src/opentelemetry/instrumentation/agentscope/shared/constants.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@
66
from enum import Enum
77

88
# Environment Variables
9-
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT = "OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT"
10-
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT_MAX_LENGTH = "OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT_MAX_LENGTH"
11-
OTEL_INSTRUMENTATION_GENAI_MESSAGE_STRATEGY = "OTEL_INSTRUMENTATION_GENAI_MESSAGE_STRATEGY"
9+
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT = (
10+
"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT"
11+
)
12+
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT_MAX_LENGTH = (
13+
"OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT_MAX_LENGTH"
14+
)
15+
OTEL_INSTRUMENTATION_GENAI_MESSAGE_STRATEGY = (
16+
"OTEL_INSTRUMENTATION_GENAI_MESSAGE_STRATEGY"
17+
)
1218

1319

1420
class CommonAttributes:
1521
"""Common GenAI attributes shared across all span types"""
22+
1623
GEN_AI_SPAN_KIND = "gen_ai.span.kind"
1724
GEN_AI_SYSTEM_INSTRUCTIONS = "gen_ai.system_instructions"
1825
GEN_AI_REQUEST_TOOL_DEFINITIONS = "gen_ai.tool.definitions"
@@ -24,12 +31,14 @@ class CommonAttributes:
2431

2532
class GenAiSpanKind(str, Enum):
2633
"""GenAI span kinds"""
34+
2735
LLM = "llm"
2836
EMBEDDING = "embedding"
2937
AGENT = "agent"
3038
TOOL = "tool"
3139
FORMATTER = "formatter"
3240

41+
3342
class AgentScopeGenAiProviderName(str, Enum):
3443
OLLAMA = "ollama"
3544
DASHSCOPE = "dashscope"

0 commit comments

Comments
 (0)