agentic-observability-aws 0.1.0__py3-none-any.whl
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.
- agentic_observability_aws/__init__.py +42 -0
- agentic_observability_aws/_specifications/attribute-mappings/otel-genai@0.1.0.yaml +96 -0
- agentic_observability_aws/_specifications/semantic-conventions/README.md +22 -0
- agentic_observability_aws/_specifications/semantic-conventions/target.yaml +12 -0
- agentic_observability_aws/_specifications/telemetry-schemas/README.md +9 -0
- agentic_observability_aws/_specifications/telemetry-schemas/attribute-mapping.schema.json +441 -0
- agentic_observability_aws/cli/__init__.py +5 -0
- agentic_observability_aws/cli/collector.py +40 -0
- agentic_observability_aws/cli/doctor.py +51 -0
- agentic_observability_aws/cli/main.py +41 -0
- agentic_observability_aws/cli/telemetry.py +352 -0
- agentic_observability_aws/core/__init__.py +4 -0
- agentic_observability_aws/core/findings.py +54 -0
- agentic_observability_aws/core/model.py +168 -0
- agentic_observability_aws/core/otlp_json.py +347 -0
- agentic_observability_aws/core/sdk_bridge.py +201 -0
- agentic_observability_aws/core/specs.py +50 -0
- agentic_observability_aws/diagnostics/__init__.py +4 -0
- agentic_observability_aws/diagnostics/doctor.py +342 -0
- agentic_observability_aws/exporters/__init__.py +4 -0
- agentic_observability_aws/exporters/reconciling.py +62 -0
- agentic_observability_aws/integrations/__init__.py +4 -0
- agentic_observability_aws/integrations/agentcore/__init__.py +4 -0
- agentic_observability_aws/integrations/bedrock/__init__.py +5 -0
- agentic_observability_aws/integrations/collector/__init__.py +1 -0
- agentic_observability_aws/integrations/collector/ottl.py +136 -0
- agentic_observability_aws/integrations/omni/__init__.py +4 -0
- agentic_observability_aws/integrations/strands/__init__.py +4 -0
- agentic_observability_aws/observability/__init__.py +4 -0
- agentic_observability_aws/observability/behavior/__init__.py +4 -0
- agentic_observability_aws/observability/metrics/__init__.py +4 -0
- agentic_observability_aws/observability/profiling/__init__.py +4 -0
- agentic_observability_aws/observability/topology/__init__.py +4 -0
- agentic_observability_aws/processors/__init__.py +4 -0
- agentic_observability_aws/processors/enricher/__init__.py +3 -0
- agentic_observability_aws/processors/enricher/session.py +32 -0
- agentic_observability_aws/processors/normalizer/__init__.py +4 -0
- agentic_observability_aws/processors/normalizer/engine.py +287 -0
- agentic_observability_aws/processors/normalizer/mapping.py +175 -0
- agentic_observability_aws/processors/pipeline.py +77 -0
- agentic_observability_aws/processors/redactor/__init__.py +4 -0
- agentic_observability_aws/processors/redactor/detectors.py +96 -0
- agentic_observability_aws/processors/redactor/redactor.py +219 -0
- agentic_observability_aws/processors/sampler/__init__.py +4 -0
- agentic_observability_aws/processors/validator/__init__.py +5 -0
- agentic_observability_aws/processors/validator/content.py +120 -0
- agentic_observability_aws/processors/validator/cross_span.py +242 -0
- agentic_observability_aws/processors/validator/omni.py +155 -0
- agentic_observability_aws/processors/validator/runner.py +39 -0
- agentic_observability_aws/processors/validator/weaver.py +272 -0
- agentic_observability_aws/py.typed +0 -0
- agentic_observability_aws/reliability/__init__.py +4 -0
- agentic_observability_aws/reliability/failure/__init__.py +4 -0
- agentic_observability_aws/reliability/resilience/__init__.py +4 -0
- agentic_observability_aws/reliability/slo/__init__.py +4 -0
- agentic_observability_aws/sdk.py +107 -0
- agentic_observability_aws-0.1.0.dist-info/METADATA +73 -0
- agentic_observability_aws-0.1.0.dist-info/RECORD +60 -0
- agentic_observability_aws-0.1.0.dist-info/WHEEL +4 -0
- agentic_observability_aws-0.1.0.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""agentic-observability-aws: AWS-first, OpenTelemetry-native toolkit for agentic AI telemetry.
|
|
2
|
+
|
|
3
|
+
v0.1 public API:
|
|
4
|
+
|
|
5
|
+
* :func:`configure` attaches reconciliation, ``session.id`` enrichment and fail-closed redaction
|
|
6
|
+
to the TracerProvider that is already installed (ADOT, Strands, or your own).
|
|
7
|
+
* :class:`ReconcilingSpanExporter` wraps one exporter explicitly.
|
|
8
|
+
* :class:`Pipeline` and :func:`validate` work on OTLP/JSON loaded with :func:`load_otlp_json`.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
12
|
+
|
|
13
|
+
from agentic_observability_aws.core.findings import Finding, Severity
|
|
14
|
+
from agentic_observability_aws.core.otlp_json import dumps as dump_otlp_json
|
|
15
|
+
from agentic_observability_aws.core.otlp_json import load as load_otlp_json
|
|
16
|
+
from agentic_observability_aws.exporters.reconciling import ReconcilingSpanExporter
|
|
17
|
+
from agentic_observability_aws.processors.pipeline import Pipeline, PipelineConfig
|
|
18
|
+
from agentic_observability_aws.processors.redactor.redactor import RedactionPolicy
|
|
19
|
+
from agentic_observability_aws.processors.validator.runner import ValidationOptions, validate
|
|
20
|
+
from agentic_observability_aws.sdk import ConfigurationError, ConfigureResult, configure
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
__version__ = version("agentic-observability-aws")
|
|
24
|
+
except PackageNotFoundError: # pragma: no cover - running from a source tree without install
|
|
25
|
+
__version__ = "0.0.0"
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"ConfigurationError",
|
|
29
|
+
"ConfigureResult",
|
|
30
|
+
"Finding",
|
|
31
|
+
"Pipeline",
|
|
32
|
+
"PipelineConfig",
|
|
33
|
+
"ReconcilingSpanExporter",
|
|
34
|
+
"RedactionPolicy",
|
|
35
|
+
"Severity",
|
|
36
|
+
"ValidationOptions",
|
|
37
|
+
"__version__",
|
|
38
|
+
"configure",
|
|
39
|
+
"dump_otlp_json",
|
|
40
|
+
"load_otlp_json",
|
|
41
|
+
"validate",
|
|
42
|
+
]
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Reconciliation rules: source telemetry -> semantic-conventions-genai v0.1.0.
|
|
2
|
+
# Schema: specifications/telemetry-schemas/attribute-mapping.schema.json (ADR-0003).
|
|
3
|
+
# Every rule cites the fixture that shows the source behaviour and the contract test pinning it
|
|
4
|
+
# (packages/python/tests/test_fixture_contracts.py). Rules are idempotent.
|
|
5
|
+
#
|
|
6
|
+
# applies_to entries are `<source>@<verified version>[/<capture mode>]`. A rule runs on every span
|
|
7
|
+
# whose instrumentation scope matches the source. When the scope reports a different version, the
|
|
8
|
+
# rule still runs and the engine reports MAPPING-VERSION-UNVERIFIED (info) once per source version.
|
|
9
|
+
# The capture-mode suffix records where the evidence came from; rules are written to be no-ops
|
|
10
|
+
# when their trigger attributes are absent, so they are safe in every mode.
|
|
11
|
+
schema_version: 1
|
|
12
|
+
target: otel-genai@0.1.0
|
|
13
|
+
|
|
14
|
+
sources:
|
|
15
|
+
strands-agents:
|
|
16
|
+
scope_name_prefixes: ["strands."]
|
|
17
|
+
opentelemetry-instrumentation-botocore:
|
|
18
|
+
scope_name_prefixes: ["opentelemetry.instrumentation.botocore"]
|
|
19
|
+
|
|
20
|
+
rules:
|
|
21
|
+
- id: rename-gen-ai-system
|
|
22
|
+
applies_to: [strands-agents@1.68.0/default, opentelemetry-instrumentation-botocore@0.66b2]
|
|
23
|
+
action: rename
|
|
24
|
+
from: gen_ai.system
|
|
25
|
+
to: gen_ai.provider.name
|
|
26
|
+
on_conflict: keep_target
|
|
27
|
+
evidence:
|
|
28
|
+
fixtures: [strands/1.68.0/default/single_agent_tool.json, botocore/0.66b2/converse_success.json]
|
|
29
|
+
tests: [test_strands_provider_attribute_by_mode, test_botocore_converse_uses_deprecated_gen_ai_system]
|
|
30
|
+
|
|
31
|
+
- id: drop-framework-as-provider
|
|
32
|
+
description: >
|
|
33
|
+
Strands sets gen_ai.provider.name to the framework name ("strands-agents"). v0.1.0 does not require
|
|
34
|
+
the attribute on internal invoke_agent spans, and on chat spans it must name the model provider.
|
|
35
|
+
Remove it on agent, cycle and tool spans. On chat spans, replace it when the provider can be
|
|
36
|
+
derived (first matching entry in `derive`); otherwise remove it and report finding
|
|
37
|
+
GENAI-PROVIDER-UNKNOWN.
|
|
38
|
+
applies_to: [strands-agents@1.68.0]
|
|
39
|
+
action: provider_fixup
|
|
40
|
+
when: {attribute: gen_ai.provider.name, equals: strands-agents}
|
|
41
|
+
model_operations: [chat, text_completion, generate_content]
|
|
42
|
+
derive:
|
|
43
|
+
# A child span from model-client instrumentation (for example botocore under a Strands
|
|
44
|
+
# BedrockModel call) already names the real provider.
|
|
45
|
+
- from: child_provider
|
|
46
|
+
# Bedrock model IDs, inference-profile IDs and ARNs (RE2-compatible, reused in OTTL).
|
|
47
|
+
- from: request_model
|
|
48
|
+
matches: '^(arn:aws[a-z-]*:bedrock:|((us|eu|apac|global|jp|au|ca|us-gov)\.)?(amazon|anthropic|ai21|cohere|deepseek|meta|mistral|openai|qwen|stability|twelvelabs|writer|luma|google|minimax|moonshot|moonshotai|nvidia)\.)'
|
|
49
|
+
provider: aws.bedrock
|
|
50
|
+
evidence:
|
|
51
|
+
fixtures: [strands/1.68.0/gen_ai_latest_experimental/single_agent_tool.json]
|
|
52
|
+
tests: [test_strands_provider_attribute_by_mode]
|
|
53
|
+
|
|
54
|
+
- id: rename-prompt-tokens
|
|
55
|
+
applies_to: [strands-agents@1.68.0]
|
|
56
|
+
action: rename
|
|
57
|
+
from: gen_ai.usage.prompt_tokens
|
|
58
|
+
to: gen_ai.usage.input_tokens
|
|
59
|
+
on_conflict: keep_target
|
|
60
|
+
evidence: {tests: [test_strands_still_emits_deprecated_prompt_completion_tokens]}
|
|
61
|
+
|
|
62
|
+
- id: rename-completion-tokens
|
|
63
|
+
applies_to: [strands-agents@1.68.0]
|
|
64
|
+
action: rename
|
|
65
|
+
from: gen_ai.usage.completion_tokens
|
|
66
|
+
to: gen_ai.usage.output_tokens
|
|
67
|
+
on_conflict: keep_target
|
|
68
|
+
evidence: {tests: [test_strands_still_emits_deprecated_prompt_completion_tokens]}
|
|
69
|
+
|
|
70
|
+
- id: rename-cache-creation
|
|
71
|
+
applies_to: [strands-agents@1.68.0]
|
|
72
|
+
action: rename
|
|
73
|
+
from: gen_ai.usage.cache_creation.input_tokens
|
|
74
|
+
to: gen_ai.usage.cache_write.input_tokens
|
|
75
|
+
on_conflict: keep_target
|
|
76
|
+
evidence: {tests: [test_strands_latest_uses_pre_v0_1_0_cache_write_name]}
|
|
77
|
+
|
|
78
|
+
- id: drop-legacy-cache-aliases
|
|
79
|
+
applies_to: [strands-agents@1.68.0/default]
|
|
80
|
+
action: remove
|
|
81
|
+
attributes: [gen_ai.usage.cache_read_input_tokens, gen_ai.usage.cache_write_input_tokens]
|
|
82
|
+
evidence: {fixtures: [strands/1.68.0/default/single_agent_tool.json]}
|
|
83
|
+
|
|
84
|
+
- id: agent-span-usage-not-additive
|
|
85
|
+
description: >
|
|
86
|
+
Strands copies the summed child chat-span usage onto invoke_agent spans. v0.1.0 removes cache usage
|
|
87
|
+
from internal invoke_agent spans. In "model-spans-only" mode (the default), remove gen_ai.usage.*
|
|
88
|
+
from invoke_agent spans that have chat descendants carrying usage, and record the removed totals
|
|
89
|
+
as agentic_observability_aws.rollup.usage.* so they are not lost.
|
|
90
|
+
applies_to: [strands-agents@1.68.0]
|
|
91
|
+
action: usage_rollup
|
|
92
|
+
span: {attribute: gen_ai.operation.name, equals: invoke_agent}
|
|
93
|
+
descendant: {attribute: gen_ai.operation.name, equals: chat}
|
|
94
|
+
usage_prefix: gen_ai.usage.
|
|
95
|
+
rollup_prefix: agentic_observability_aws.rollup.usage.
|
|
96
|
+
evidence: {tests: [test_strands_agent_span_repeats_child_model_usage]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Semantic conventions
|
|
2
|
+
|
|
3
|
+
The toolkit targets **semantic-conventions-genai v0.1.0** (on core semconv **v1.45.0**). See
|
|
4
|
+
[target.yaml](target.yaml).
|
|
5
|
+
|
|
6
|
+
Why this version: since core semconv v1.42.0, GenAI attributes in the core registry are deprecated
|
|
7
|
+
with "Moved to the OpenTelemetry GenAI semantic conventions repository"
|
|
8
|
+
(`opentelemetry-semantic-conventions` 0.66b2). v0.1.0 is that repository's first and only release.
|
|
9
|
+
|
|
10
|
+
Breaking changes in v0.1.0 that affect the captured sources (`tests/fixtures/`):
|
|
11
|
+
|
|
12
|
+
| v0.1.0 change | Strands 1.68.0 | botocore 0.66b2 |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| `gen_ai.system` → `gen_ai.provider.name` | default mode emits `gen_ai.system` | emits `gen_ai.system` |
|
|
15
|
+
| `gen_ai.usage.cache_creation.input_tokens` → `cache_write.input_tokens` | emits the old name in both modes | n/a |
|
|
16
|
+
| Cache usage removed from internal `invoke_agent` span | present on agent span | n/a |
|
|
17
|
+
| JSON-schema attributes need structured values, not JSON strings | `gen_ai.system_instructions`, `gen_ai.agent.tools` are JSON strings | n/a |
|
|
18
|
+
| `gen_ai.client.token.usage` histogram replaced by `gen_ai.client.inference.operation.{input,output}_tokens` | n/a | emits the old histogram |
|
|
19
|
+
| `gen_ai.client.operation.duration` no longer used for inference → `gen_ai.client.inference.duration` | n/a | emits the old histogram |
|
|
20
|
+
|
|
21
|
+
Long-deprecated names that Strands still emits in both modes: `gen_ai.usage.prompt_tokens` and
|
|
22
|
+
`gen_ai.usage.completion_tokens`.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Convention versions the toolkit targets. One place; everything else references this file.
|
|
2
|
+
genai:
|
|
3
|
+
repository: https://github.com/open-telemetry/semantic-conventions-genai
|
|
4
|
+
version: v0.1.0 # released 2026-11-21; first standalone GenAI release
|
|
5
|
+
depends_on_core: v1.45.0 # https://github.com/open-telemetry/semantic-conventions
|
|
6
|
+
core:
|
|
7
|
+
repository: https://github.com/open-telemetry/semantic-conventions
|
|
8
|
+
version: v1.45.0
|
|
9
|
+
validation_tool:
|
|
10
|
+
name: OpenTelemetry Weaver
|
|
11
|
+
version: v0.28.0
|
|
12
|
+
role: per-span registry conformance (missing attributes, type mismatches) via `weaver registry live-check`
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Telemetry schemas
|
|
2
|
+
|
|
3
|
+
| File | Validates |
|
|
4
|
+
|---|---|
|
|
5
|
+
| [attribute-mapping.schema.json](attribute-mapping.schema.json) | `attribute-mappings/*.yaml` (ADR-0003) |
|
|
6
|
+
|
|
7
|
+
`attribute-mapping.schema.json` is generated from the Python loader's models
|
|
8
|
+
(`agentic_observability_aws.processors.normalizer.mapping.mapping_json_schema()`); a test fails
|
|
9
|
+
when the two drift. Validation-profile files arrive with configurable profiles (v0.2+).
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$defs": {
|
|
3
|
+
"ChildProviderDerivation": {
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"properties": {
|
|
6
|
+
"from": {
|
|
7
|
+
"const": "child_provider",
|
|
8
|
+
"title": "From",
|
|
9
|
+
"type": "string"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"required": [
|
|
13
|
+
"from"
|
|
14
|
+
],
|
|
15
|
+
"title": "ChildProviderDerivation",
|
|
16
|
+
"type": "object"
|
|
17
|
+
},
|
|
18
|
+
"Condition": {
|
|
19
|
+
"additionalProperties": false,
|
|
20
|
+
"properties": {
|
|
21
|
+
"attribute": {
|
|
22
|
+
"pattern": "^[a-z0-9_][a-z0-9_.\\-]*$",
|
|
23
|
+
"title": "Attribute",
|
|
24
|
+
"type": "string"
|
|
25
|
+
},
|
|
26
|
+
"equals": {
|
|
27
|
+
"anyOf": [
|
|
28
|
+
{
|
|
29
|
+
"type": "string"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"type": "integer"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"type": "boolean"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"title": "Equals"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"required": [
|
|
42
|
+
"attribute",
|
|
43
|
+
"equals"
|
|
44
|
+
],
|
|
45
|
+
"title": "Condition",
|
|
46
|
+
"type": "object"
|
|
47
|
+
},
|
|
48
|
+
"Evidence": {
|
|
49
|
+
"additionalProperties": false,
|
|
50
|
+
"properties": {
|
|
51
|
+
"fixtures": {
|
|
52
|
+
"items": {
|
|
53
|
+
"type": "string"
|
|
54
|
+
},
|
|
55
|
+
"title": "Fixtures",
|
|
56
|
+
"type": "array"
|
|
57
|
+
},
|
|
58
|
+
"tests": {
|
|
59
|
+
"items": {
|
|
60
|
+
"type": "string"
|
|
61
|
+
},
|
|
62
|
+
"title": "Tests",
|
|
63
|
+
"type": "array"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"title": "Evidence",
|
|
67
|
+
"type": "object"
|
|
68
|
+
},
|
|
69
|
+
"ProviderFixupRule": {
|
|
70
|
+
"additionalProperties": false,
|
|
71
|
+
"properties": {
|
|
72
|
+
"action": {
|
|
73
|
+
"const": "provider_fixup",
|
|
74
|
+
"title": "Action",
|
|
75
|
+
"type": "string"
|
|
76
|
+
},
|
|
77
|
+
"applies_to": {
|
|
78
|
+
"items": {
|
|
79
|
+
"pattern": "^[a-z0-9][a-z0-9_.\\-]*@[0-9A-Za-z.\\-+]+(/[a-z0-9_]+)?$",
|
|
80
|
+
"type": "string"
|
|
81
|
+
},
|
|
82
|
+
"minItems": 1,
|
|
83
|
+
"title": "Applies To",
|
|
84
|
+
"type": "array"
|
|
85
|
+
},
|
|
86
|
+
"derive": {
|
|
87
|
+
"items": {
|
|
88
|
+
"discriminator": {
|
|
89
|
+
"mapping": {
|
|
90
|
+
"child_provider": "#/$defs/ChildProviderDerivation",
|
|
91
|
+
"request_model": "#/$defs/RequestModelDerivation"
|
|
92
|
+
},
|
|
93
|
+
"propertyName": "from"
|
|
94
|
+
},
|
|
95
|
+
"oneOf": [
|
|
96
|
+
{
|
|
97
|
+
"$ref": "#/$defs/ChildProviderDerivation"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"$ref": "#/$defs/RequestModelDerivation"
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
"title": "Derive",
|
|
105
|
+
"type": "array"
|
|
106
|
+
},
|
|
107
|
+
"description": {
|
|
108
|
+
"anyOf": [
|
|
109
|
+
{
|
|
110
|
+
"type": "string"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"type": "null"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"default": null,
|
|
117
|
+
"title": "Description"
|
|
118
|
+
},
|
|
119
|
+
"evidence": {
|
|
120
|
+
"$ref": "#/$defs/Evidence"
|
|
121
|
+
},
|
|
122
|
+
"id": {
|
|
123
|
+
"pattern": "^[a-z0-9][a-z0-9\\-]*$",
|
|
124
|
+
"title": "Id",
|
|
125
|
+
"type": "string"
|
|
126
|
+
},
|
|
127
|
+
"model_operations": {
|
|
128
|
+
"items": {
|
|
129
|
+
"type": "string"
|
|
130
|
+
},
|
|
131
|
+
"title": "Model Operations",
|
|
132
|
+
"type": "array"
|
|
133
|
+
},
|
|
134
|
+
"when": {
|
|
135
|
+
"$ref": "#/$defs/Condition"
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"required": [
|
|
139
|
+
"id",
|
|
140
|
+
"applies_to",
|
|
141
|
+
"evidence",
|
|
142
|
+
"action",
|
|
143
|
+
"when"
|
|
144
|
+
],
|
|
145
|
+
"title": "ProviderFixupRule",
|
|
146
|
+
"type": "object"
|
|
147
|
+
},
|
|
148
|
+
"RemoveRule": {
|
|
149
|
+
"additionalProperties": false,
|
|
150
|
+
"properties": {
|
|
151
|
+
"action": {
|
|
152
|
+
"const": "remove",
|
|
153
|
+
"title": "Action",
|
|
154
|
+
"type": "string"
|
|
155
|
+
},
|
|
156
|
+
"applies_to": {
|
|
157
|
+
"items": {
|
|
158
|
+
"pattern": "^[a-z0-9][a-z0-9_.\\-]*@[0-9A-Za-z.\\-+]+(/[a-z0-9_]+)?$",
|
|
159
|
+
"type": "string"
|
|
160
|
+
},
|
|
161
|
+
"minItems": 1,
|
|
162
|
+
"title": "Applies To",
|
|
163
|
+
"type": "array"
|
|
164
|
+
},
|
|
165
|
+
"attributes": {
|
|
166
|
+
"items": {
|
|
167
|
+
"pattern": "^[a-z0-9_][a-z0-9_.\\-]*$",
|
|
168
|
+
"type": "string"
|
|
169
|
+
},
|
|
170
|
+
"minItems": 1,
|
|
171
|
+
"title": "Attributes",
|
|
172
|
+
"type": "array"
|
|
173
|
+
},
|
|
174
|
+
"description": {
|
|
175
|
+
"anyOf": [
|
|
176
|
+
{
|
|
177
|
+
"type": "string"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"type": "null"
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
"default": null,
|
|
184
|
+
"title": "Description"
|
|
185
|
+
},
|
|
186
|
+
"evidence": {
|
|
187
|
+
"$ref": "#/$defs/Evidence"
|
|
188
|
+
},
|
|
189
|
+
"id": {
|
|
190
|
+
"pattern": "^[a-z0-9][a-z0-9\\-]*$",
|
|
191
|
+
"title": "Id",
|
|
192
|
+
"type": "string"
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
"required": [
|
|
196
|
+
"id",
|
|
197
|
+
"applies_to",
|
|
198
|
+
"evidence",
|
|
199
|
+
"action",
|
|
200
|
+
"attributes"
|
|
201
|
+
],
|
|
202
|
+
"title": "RemoveRule",
|
|
203
|
+
"type": "object"
|
|
204
|
+
},
|
|
205
|
+
"RenameRule": {
|
|
206
|
+
"additionalProperties": false,
|
|
207
|
+
"properties": {
|
|
208
|
+
"action": {
|
|
209
|
+
"const": "rename",
|
|
210
|
+
"title": "Action",
|
|
211
|
+
"type": "string"
|
|
212
|
+
},
|
|
213
|
+
"applies_to": {
|
|
214
|
+
"items": {
|
|
215
|
+
"pattern": "^[a-z0-9][a-z0-9_.\\-]*@[0-9A-Za-z.\\-+]+(/[a-z0-9_]+)?$",
|
|
216
|
+
"type": "string"
|
|
217
|
+
},
|
|
218
|
+
"minItems": 1,
|
|
219
|
+
"title": "Applies To",
|
|
220
|
+
"type": "array"
|
|
221
|
+
},
|
|
222
|
+
"description": {
|
|
223
|
+
"anyOf": [
|
|
224
|
+
{
|
|
225
|
+
"type": "string"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"type": "null"
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
"default": null,
|
|
232
|
+
"title": "Description"
|
|
233
|
+
},
|
|
234
|
+
"evidence": {
|
|
235
|
+
"$ref": "#/$defs/Evidence"
|
|
236
|
+
},
|
|
237
|
+
"from": {
|
|
238
|
+
"pattern": "^[a-z0-9_][a-z0-9_.\\-]*$",
|
|
239
|
+
"title": "From",
|
|
240
|
+
"type": "string"
|
|
241
|
+
},
|
|
242
|
+
"id": {
|
|
243
|
+
"pattern": "^[a-z0-9][a-z0-9\\-]*$",
|
|
244
|
+
"title": "Id",
|
|
245
|
+
"type": "string"
|
|
246
|
+
},
|
|
247
|
+
"on_conflict": {
|
|
248
|
+
"default": "keep_target",
|
|
249
|
+
"enum": [
|
|
250
|
+
"keep_target",
|
|
251
|
+
"keep_source"
|
|
252
|
+
],
|
|
253
|
+
"title": "On Conflict",
|
|
254
|
+
"type": "string"
|
|
255
|
+
},
|
|
256
|
+
"to": {
|
|
257
|
+
"pattern": "^[a-z0-9_][a-z0-9_.\\-]*$",
|
|
258
|
+
"title": "To",
|
|
259
|
+
"type": "string"
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
"required": [
|
|
263
|
+
"id",
|
|
264
|
+
"applies_to",
|
|
265
|
+
"evidence",
|
|
266
|
+
"action",
|
|
267
|
+
"from",
|
|
268
|
+
"to"
|
|
269
|
+
],
|
|
270
|
+
"title": "RenameRule",
|
|
271
|
+
"type": "object"
|
|
272
|
+
},
|
|
273
|
+
"RequestModelDerivation": {
|
|
274
|
+
"additionalProperties": false,
|
|
275
|
+
"properties": {
|
|
276
|
+
"from": {
|
|
277
|
+
"const": "request_model",
|
|
278
|
+
"title": "From",
|
|
279
|
+
"type": "string"
|
|
280
|
+
},
|
|
281
|
+
"matches": {
|
|
282
|
+
"title": "Matches",
|
|
283
|
+
"type": "string"
|
|
284
|
+
},
|
|
285
|
+
"provider": {
|
|
286
|
+
"title": "Provider",
|
|
287
|
+
"type": "string"
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
"required": [
|
|
291
|
+
"from",
|
|
292
|
+
"matches",
|
|
293
|
+
"provider"
|
|
294
|
+
],
|
|
295
|
+
"title": "RequestModelDerivation",
|
|
296
|
+
"type": "object"
|
|
297
|
+
},
|
|
298
|
+
"SourceSpec": {
|
|
299
|
+
"additionalProperties": false,
|
|
300
|
+
"properties": {
|
|
301
|
+
"scope_name_prefixes": {
|
|
302
|
+
"items": {
|
|
303
|
+
"type": "string"
|
|
304
|
+
},
|
|
305
|
+
"minItems": 1,
|
|
306
|
+
"title": "Scope Name Prefixes",
|
|
307
|
+
"type": "array"
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
"required": [
|
|
311
|
+
"scope_name_prefixes"
|
|
312
|
+
],
|
|
313
|
+
"title": "SourceSpec",
|
|
314
|
+
"type": "object"
|
|
315
|
+
},
|
|
316
|
+
"UsageRollupRule": {
|
|
317
|
+
"additionalProperties": false,
|
|
318
|
+
"properties": {
|
|
319
|
+
"action": {
|
|
320
|
+
"const": "usage_rollup",
|
|
321
|
+
"title": "Action",
|
|
322
|
+
"type": "string"
|
|
323
|
+
},
|
|
324
|
+
"applies_to": {
|
|
325
|
+
"items": {
|
|
326
|
+
"pattern": "^[a-z0-9][a-z0-9_.\\-]*@[0-9A-Za-z.\\-+]+(/[a-z0-9_]+)?$",
|
|
327
|
+
"type": "string"
|
|
328
|
+
},
|
|
329
|
+
"minItems": 1,
|
|
330
|
+
"title": "Applies To",
|
|
331
|
+
"type": "array"
|
|
332
|
+
},
|
|
333
|
+
"descendant": {
|
|
334
|
+
"$ref": "#/$defs/Condition"
|
|
335
|
+
},
|
|
336
|
+
"description": {
|
|
337
|
+
"anyOf": [
|
|
338
|
+
{
|
|
339
|
+
"type": "string"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"type": "null"
|
|
343
|
+
}
|
|
344
|
+
],
|
|
345
|
+
"default": null,
|
|
346
|
+
"title": "Description"
|
|
347
|
+
},
|
|
348
|
+
"evidence": {
|
|
349
|
+
"$ref": "#/$defs/Evidence"
|
|
350
|
+
},
|
|
351
|
+
"id": {
|
|
352
|
+
"pattern": "^[a-z0-9][a-z0-9\\-]*$",
|
|
353
|
+
"title": "Id",
|
|
354
|
+
"type": "string"
|
|
355
|
+
},
|
|
356
|
+
"rollup_prefix": {
|
|
357
|
+
"default": "agentic_observability_aws.rollup.usage.",
|
|
358
|
+
"title": "Rollup Prefix",
|
|
359
|
+
"type": "string"
|
|
360
|
+
},
|
|
361
|
+
"span": {
|
|
362
|
+
"$ref": "#/$defs/Condition"
|
|
363
|
+
},
|
|
364
|
+
"usage_prefix": {
|
|
365
|
+
"default": "gen_ai.usage.",
|
|
366
|
+
"title": "Usage Prefix",
|
|
367
|
+
"type": "string"
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
"required": [
|
|
371
|
+
"id",
|
|
372
|
+
"applies_to",
|
|
373
|
+
"evidence",
|
|
374
|
+
"action",
|
|
375
|
+
"span",
|
|
376
|
+
"descendant"
|
|
377
|
+
],
|
|
378
|
+
"title": "UsageRollupRule",
|
|
379
|
+
"type": "object"
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
"$id": "https://github.com/aws-ai-observability/dev-tools/specifications/telemetry-schemas/attribute-mapping.schema.json",
|
|
383
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
384
|
+
"additionalProperties": false,
|
|
385
|
+
"properties": {
|
|
386
|
+
"rules": {
|
|
387
|
+
"items": {
|
|
388
|
+
"discriminator": {
|
|
389
|
+
"mapping": {
|
|
390
|
+
"provider_fixup": "#/$defs/ProviderFixupRule",
|
|
391
|
+
"remove": "#/$defs/RemoveRule",
|
|
392
|
+
"rename": "#/$defs/RenameRule",
|
|
393
|
+
"usage_rollup": "#/$defs/UsageRollupRule"
|
|
394
|
+
},
|
|
395
|
+
"propertyName": "action"
|
|
396
|
+
},
|
|
397
|
+
"oneOf": [
|
|
398
|
+
{
|
|
399
|
+
"$ref": "#/$defs/RenameRule"
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
"$ref": "#/$defs/RemoveRule"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
"$ref": "#/$defs/ProviderFixupRule"
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
"$ref": "#/$defs/UsageRollupRule"
|
|
409
|
+
}
|
|
410
|
+
]
|
|
411
|
+
},
|
|
412
|
+
"title": "Rules",
|
|
413
|
+
"type": "array"
|
|
414
|
+
},
|
|
415
|
+
"schema_version": {
|
|
416
|
+
"const": 1,
|
|
417
|
+
"title": "Schema Version",
|
|
418
|
+
"type": "integer"
|
|
419
|
+
},
|
|
420
|
+
"sources": {
|
|
421
|
+
"additionalProperties": {
|
|
422
|
+
"$ref": "#/$defs/SourceSpec"
|
|
423
|
+
},
|
|
424
|
+
"title": "Sources",
|
|
425
|
+
"type": "object"
|
|
426
|
+
},
|
|
427
|
+
"target": {
|
|
428
|
+
"pattern": "^[a-z0-9\\-]+@[0-9A-Za-z.\\-+]+$",
|
|
429
|
+
"title": "Target",
|
|
430
|
+
"type": "string"
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
"required": [
|
|
434
|
+
"schema_version",
|
|
435
|
+
"target",
|
|
436
|
+
"sources",
|
|
437
|
+
"rules"
|
|
438
|
+
],
|
|
439
|
+
"title": "agentic-observability-aws attribute mapping file",
|
|
440
|
+
"type": "object"
|
|
441
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""``collector ottl``: generate Collector ``transform`` statements (backlog V-12)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Annotated
|
|
7
|
+
|
|
8
|
+
import typer
|
|
9
|
+
|
|
10
|
+
from agentic_observability_aws.core.specs import DEFAULT_MAPPING
|
|
11
|
+
from agentic_observability_aws.integrations.collector import ottl
|
|
12
|
+
|
|
13
|
+
app = typer.Typer(help="OpenTelemetry Collector helpers.", no_args_is_help=True)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@app.command("ottl")
|
|
17
|
+
def ottl_cmd(
|
|
18
|
+
mapping: Annotated[str, typer.Option(help="Mapping profile name.")] = DEFAULT_MAPPING,
|
|
19
|
+
write: Annotated[
|
|
20
|
+
Path | None,
|
|
21
|
+
typer.Option(help="Update the generated region of this Collector config in place."),
|
|
22
|
+
] = None,
|
|
23
|
+
check: Annotated[
|
|
24
|
+
Path | None,
|
|
25
|
+
typer.Option(help="Exit 1 if this Collector config's generated region is out of date."),
|
|
26
|
+
] = None,
|
|
27
|
+
) -> None:
|
|
28
|
+
"""Print the transform/genai processor block generated from a mapping file."""
|
|
29
|
+
if write is not None:
|
|
30
|
+
changed = ottl.write(write, mapping)
|
|
31
|
+
typer.echo(f"{write}: {'updated' if changed else 'already up to date'}", err=True)
|
|
32
|
+
return
|
|
33
|
+
if check is not None:
|
|
34
|
+
text = check.read_text(encoding="utf-8")
|
|
35
|
+
if ottl.splice(text, ottl.render_for(mapping)) != text:
|
|
36
|
+
typer.echo(f"{check}: generated OTTL is out of date; run with --write", err=True)
|
|
37
|
+
raise typer.Exit(1)
|
|
38
|
+
typer.echo(f"{check}: up to date", err=True)
|
|
39
|
+
return
|
|
40
|
+
typer.echo(ottl.render_for(mapping), nl=False)
|