nvidia-nat-opentelemetry 1.3.0a20250904__py3-none-any.whl → 1.3.0a20250909__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.
- nat/plugins/opentelemetry/__init__.py +10 -0
- nat/plugins/opentelemetry/otlp_span_redaction_adapter_exporter.py +144 -0
- nat/plugins/opentelemetry/register.py +5 -5
- {nvidia_nat_opentelemetry-1.3.0a20250904.dist-info → nvidia_nat_opentelemetry-1.3.0a20250909.dist-info}/METADATA +6 -3
- {nvidia_nat_opentelemetry-1.3.0a20250904.dist-info → nvidia_nat_opentelemetry-1.3.0a20250909.dist-info}/RECORD +8 -7
- {nvidia_nat_opentelemetry-1.3.0a20250904.dist-info → nvidia_nat_opentelemetry-1.3.0a20250909.dist-info}/WHEEL +0 -0
- {nvidia_nat_opentelemetry-1.3.0a20250904.dist-info → nvidia_nat_opentelemetry-1.3.0a20250909.dist-info}/entry_points.txt +0 -0
- {nvidia_nat_opentelemetry-1.3.0a20250904.dist-info → nvidia_nat_opentelemetry-1.3.0a20250909.dist-info}/top_level.txt +0 -0
@@ -12,3 +12,13 @@
|
|
12
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
|
+
|
16
|
+
from nat.plugins.opentelemetry.otel_span_exporter import OtelSpanExporter
|
17
|
+
from nat.plugins.opentelemetry.otlp_span_adapter_exporter import OTLPSpanAdapterExporter
|
18
|
+
from nat.plugins.opentelemetry.otlp_span_redaction_adapter_exporter import OTLPSpanHeaderRedactionAdapterExporter
|
19
|
+
|
20
|
+
__all__ = [
|
21
|
+
"OTLPSpanHeaderRedactionAdapterExporter",
|
22
|
+
"OTLPSpanAdapterExporter",
|
23
|
+
"OtelSpanExporter",
|
24
|
+
]
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
import logging
|
17
|
+
from collections.abc import Callable
|
18
|
+
|
19
|
+
from nat.builder.context import ContextState
|
20
|
+
from nat.observability.mixin.tagging_config_mixin import PrivacyLevel
|
21
|
+
from nat.observability.processor.header_redaction_processor import HeaderRedactionProcessor
|
22
|
+
from nat.observability.processor.span_tagging_processor import SpanTaggingProcessor
|
23
|
+
from nat.plugins.opentelemetry.otlp_span_adapter_exporter import OTLPSpanAdapterExporter
|
24
|
+
|
25
|
+
logger = logging.getLogger(__name__)
|
26
|
+
|
27
|
+
|
28
|
+
class OTLPSpanHeaderRedactionAdapterExporter(OTLPSpanAdapterExporter):
|
29
|
+
"""An OpenTelemetry OTLP span exporter with built-in redaction and privacy tagging.
|
30
|
+
|
31
|
+
This class extends OTLPSpanAdapterExporter to provide automatic span redaction
|
32
|
+
and privacy tagging capabilities. It automatically adds header-based redaction
|
33
|
+
and span tagging processors to the processing pipeline.
|
34
|
+
|
35
|
+
Key Features:
|
36
|
+
- Header-based span redaction with configurable callback logic
|
37
|
+
- Privacy level tagging for compliance and governance
|
38
|
+
- Complete span processing pipeline (IntermediateStep → Span → Redaction → Tagging → OtelSpan → Batching → Export)
|
39
|
+
- Batching support for efficient transmission
|
40
|
+
- OTLP HTTP protocol for maximum compatibility
|
41
|
+
- Configurable authentication via headers
|
42
|
+
- Resource attribute management
|
43
|
+
- Error handling and retry logic
|
44
|
+
|
45
|
+
The redaction processor allows conditional redaction based on authentication headers,
|
46
|
+
while the tagging processor adds privacy-level metadata to spans for downstream
|
47
|
+
processing and compliance tracking.
|
48
|
+
|
49
|
+
This exporter is commonly used with services like:
|
50
|
+
- OpenTelemetry Collector
|
51
|
+
- DataDog (OTLP endpoint)
|
52
|
+
- Jaeger (OTLP endpoint)
|
53
|
+
- Grafana Tempo
|
54
|
+
- Custom OTLP-compatible backends
|
55
|
+
|
56
|
+
Example:
|
57
|
+
def should_redact(auth_key: str) -> bool:
|
58
|
+
return auth_key in ["sensitive_user", "test_user"]
|
59
|
+
|
60
|
+
exporter = OTLPSpanRedactionAdapterExporter(
|
61
|
+
endpoint="https://api.service.com/v1/traces",
|
62
|
+
headers={"Authorization": "Bearer your-token"},
|
63
|
+
redaction_attributes=["user.email", "request.body"],
|
64
|
+
redaction_header="x-user-id",
|
65
|
+
redaction_callback=should_redact,
|
66
|
+
redaction_value="REDACTED",
|
67
|
+
privacy_tag_key="privacy.level",
|
68
|
+
privacy_tag_value=PrivacyLevel.HIGH,
|
69
|
+
batch_size=50,
|
70
|
+
flush_interval=10.0
|
71
|
+
)
|
72
|
+
"""
|
73
|
+
|
74
|
+
def __init__(
|
75
|
+
self,
|
76
|
+
*,
|
77
|
+
# OtelSpanExporter args
|
78
|
+
context_state: ContextState | None = None,
|
79
|
+
batch_size: int = 100,
|
80
|
+
flush_interval: float = 5.0,
|
81
|
+
max_queue_size: int = 1000,
|
82
|
+
drop_on_overflow: bool = False,
|
83
|
+
shutdown_timeout: float = 10.0,
|
84
|
+
resource_attributes: dict[str, str] | None = None,
|
85
|
+
# Redaction args
|
86
|
+
redaction_attributes: list[str] | None = None,
|
87
|
+
redaction_header: str | None = None,
|
88
|
+
redaction_callback: Callable[[str], bool] | None = None,
|
89
|
+
redaction_enabled: bool = False,
|
90
|
+
force_redaction: bool = False,
|
91
|
+
redaction_value: str = "[REDACTED]",
|
92
|
+
privacy_tag_key: str | None = None,
|
93
|
+
privacy_tag_value: PrivacyLevel | None = None,
|
94
|
+
# OTLPSpanExporterMixin args
|
95
|
+
endpoint: str,
|
96
|
+
headers: dict[str, str] | None = None,
|
97
|
+
**otlp_kwargs):
|
98
|
+
"""Initialize the OTLP span exporter with redaction and tagging capabilities.
|
99
|
+
|
100
|
+
Args:
|
101
|
+
context_state: The context state for the exporter.
|
102
|
+
batch_size: Number of spans to batch before exporting.
|
103
|
+
flush_interval: Time in seconds between automatic batch flushes.
|
104
|
+
max_queue_size: Maximum number of spans to queue.
|
105
|
+
drop_on_overflow: Whether to drop spans when queue is full.
|
106
|
+
shutdown_timeout: Maximum time to wait for export completion during shutdown.
|
107
|
+
resource_attributes: Additional resource attributes for spans.
|
108
|
+
redaction_attributes: List of span attribute keys to redact when conditions are met.
|
109
|
+
redaction_header: Header key to check for authentication/user identification.
|
110
|
+
redaction_callback: Function to determine if spans should be redacted based on header value.
|
111
|
+
redaction_enabled: Whether the redaction processor is enabled.
|
112
|
+
force_redaction: If True, always redact regardless of header checks.
|
113
|
+
redaction_value: Value to replace redacted attributes with.
|
114
|
+
privacy_tag_key: Key name for the privacy level tag to add to spans.
|
115
|
+
privacy_tag_value: Privacy level value to assign to spans.
|
116
|
+
endpoint: The endpoint for the OTLP service.
|
117
|
+
headers: The headers for the OTLP service.
|
118
|
+
**otlp_kwargs: Additional keyword arguments for the OTLP service.
|
119
|
+
"""
|
120
|
+
super().__init__(context_state=context_state,
|
121
|
+
batch_size=batch_size,
|
122
|
+
flush_interval=flush_interval,
|
123
|
+
max_queue_size=max_queue_size,
|
124
|
+
drop_on_overflow=drop_on_overflow,
|
125
|
+
shutdown_timeout=shutdown_timeout,
|
126
|
+
resource_attributes=resource_attributes,
|
127
|
+
endpoint=endpoint,
|
128
|
+
headers=headers,
|
129
|
+
**otlp_kwargs)
|
130
|
+
|
131
|
+
# Insert redaction and tagging processors to the front of the processing pipeline
|
132
|
+
self.add_processor(HeaderRedactionProcessor(attributes=redaction_attributes,
|
133
|
+
header=redaction_header,
|
134
|
+
callback=redaction_callback,
|
135
|
+
enabled=redaction_enabled,
|
136
|
+
force_redact=force_redaction,
|
137
|
+
redaction_value=redaction_value),
|
138
|
+
name="header_redaction",
|
139
|
+
position=0)
|
140
|
+
|
141
|
+
self.add_processor(SpanTaggingProcessor(tag_key=privacy_tag_key,
|
142
|
+
tag_value=privacy_tag_value.value if privacy_tag_value else None),
|
143
|
+
name="span_privacy_tagging",
|
144
|
+
position=1)
|
@@ -42,7 +42,7 @@ async def langfuse_telemetry_exporter(config: LangfuseTelemetryExporter, builder
|
|
42
42
|
|
43
43
|
import base64
|
44
44
|
|
45
|
-
from nat.plugins.opentelemetry
|
45
|
+
from nat.plugins.opentelemetry import OTLPSpanAdapterExporter
|
46
46
|
|
47
47
|
secret_key = config.secret_key or os.environ.get("LANGFUSE_SECRET_KEY")
|
48
48
|
public_key = config.public_key or os.environ.get("LANGFUSE_PUBLIC_KEY")
|
@@ -78,7 +78,7 @@ class LangsmithTelemetryExporter(BatchConfigMixin, CollectorConfigMixin, Telemet
|
|
78
78
|
async def langsmith_telemetry_exporter(config: LangsmithTelemetryExporter, builder: Builder):
|
79
79
|
"""Create a Langsmith telemetry exporter."""
|
80
80
|
|
81
|
-
from nat.plugins.opentelemetry
|
81
|
+
from nat.plugins.opentelemetry import OTLPSpanAdapterExporter
|
82
82
|
|
83
83
|
api_key = config.api_key or os.environ.get("LANGSMITH_API_KEY")
|
84
84
|
if not api_key:
|
@@ -108,8 +108,8 @@ class OtelCollectorTelemetryExporter(BatchConfigMixin,
|
|
108
108
|
async def otel_telemetry_exporter(config: OtelCollectorTelemetryExporter, builder: Builder):
|
109
109
|
"""Create an OpenTelemetry telemetry exporter."""
|
110
110
|
|
111
|
+
from nat.plugins.opentelemetry import OTLPSpanAdapterExporter
|
111
112
|
from nat.plugins.opentelemetry.otel_span_exporter import get_opentelemetry_sdk_version
|
112
|
-
from nat.plugins.opentelemetry.otlp_span_adapter_exporter import OTLPSpanAdapterExporter
|
113
113
|
|
114
114
|
# Default resource attributes
|
115
115
|
default_resource_attributes = {
|
@@ -143,7 +143,7 @@ class PatronusTelemetryExporter(BatchConfigMixin, CollectorConfigMixin, Telemetr
|
|
143
143
|
async def patronus_telemetry_exporter(config: PatronusTelemetryExporter, builder: Builder):
|
144
144
|
"""Create a Patronus telemetry exporter."""
|
145
145
|
|
146
|
-
from nat.plugins.opentelemetry
|
146
|
+
from nat.plugins.opentelemetry import OTLPSpanAdapterExporter
|
147
147
|
|
148
148
|
api_key = config.api_key or os.environ.get("PATRONUS_API_KEY")
|
149
149
|
if not api_key:
|
@@ -175,7 +175,7 @@ class GalileoTelemetryExporter(BatchConfigMixin, CollectorConfigMixin, Telemetry
|
|
175
175
|
async def galileo_telemetry_exporter(config: GalileoTelemetryExporter, builder: Builder):
|
176
176
|
"""Create a Galileo telemetry exporter."""
|
177
177
|
|
178
|
-
from nat.plugins.opentelemetry
|
178
|
+
from nat.plugins.opentelemetry import OTLPSpanAdapterExporter
|
179
179
|
|
180
180
|
headers = {
|
181
181
|
"Galileo-API-Key": config.api_key,
|
@@ -1,12 +1,15 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nvidia-nat-opentelemetry
|
3
|
-
Version: 1.3.
|
3
|
+
Version: 1.3.0a20250909
|
4
4
|
Summary: Subpackage for OpenTelemetry integration in NeMo Agent toolkit
|
5
5
|
Keywords: ai,observability,opentelemetry
|
6
6
|
Classifier: Programming Language :: Python
|
7
|
-
|
7
|
+
Classifier: Programming Language :: Python :: 3.11
|
8
|
+
Classifier: Programming Language :: Python :: 3.12
|
9
|
+
Classifier: Programming Language :: Python :: 3.13
|
10
|
+
Requires-Python: <3.14,>=3.11
|
8
11
|
Description-Content-Type: text/markdown
|
9
|
-
Requires-Dist: nvidia-nat==v1.3.
|
12
|
+
Requires-Dist: nvidia-nat==v1.3.0a20250909
|
10
13
|
Requires-Dist: opentelemetry-api~=1.2
|
11
14
|
Requires-Dist: opentelemetry-exporter-otlp~=1.3
|
12
15
|
Requires-Dist: opentelemetry-sdk~=1.3
|
@@ -1,14 +1,15 @@
|
|
1
1
|
nat/meta/pypi.md,sha256=_o1o1BLPY1pvjCkklWxlm7LlIDMPCk-2Rho85NUuN8U,1109
|
2
|
-
nat/plugins/opentelemetry/__init__.py,sha256=
|
2
|
+
nat/plugins/opentelemetry/__init__.py,sha256=j-YKuxwSIzGziyDyunw8s_W7WiFiqKLdFjw-utwHPFk,1079
|
3
3
|
nat/plugins/opentelemetry/otel_span.py,sha256=v5Bzy4Cq51Sph5fKErZjt_UPfPXsVJx2qllj7c5afe4,16511
|
4
4
|
nat/plugins/opentelemetry/otel_span_exporter.py,sha256=YO7JsQgi8Cf2OQBJ_s78HwJjrWx9SdqMvPen3Pa2_bI,6533
|
5
5
|
nat/plugins/opentelemetry/otlp_span_adapter_exporter.py,sha256=C5MaZOB_ZijAbRZpRUtjpBsH0-FHeon81l5xAFlUKos,3945
|
6
|
-
nat/plugins/opentelemetry/
|
6
|
+
nat/plugins/opentelemetry/otlp_span_redaction_adapter_exporter.py,sha256=rxbTcPCYPoLinseVId4jllVP9E5NHD2vgcsy4-NsE9E,7086
|
7
|
+
nat/plugins/opentelemetry/register.py,sha256=IWPDQBIhHB7OcykOlCQ5RlMrVWjWQvoJwlgy6QCjir8,9070
|
7
8
|
nat/plugins/opentelemetry/span_converter.py,sha256=Gz3KvRNQeEBBlpaPO8YRAJkw4fmzV7m9bT6dGX0IV2E,8846
|
8
9
|
nat/plugins/opentelemetry/mixin/__init__.py,sha256=Xs1JQ16L9btwreh4pdGKwskffAw1YFO48jKrU4ib_7c,685
|
9
10
|
nat/plugins/opentelemetry/mixin/otlp_span_exporter_mixin.py,sha256=stTer5KT6l2RA93_pexoU8WqhQLCnYbjyOhIMbDEwWk,2807
|
10
|
-
nvidia_nat_opentelemetry-1.3.
|
11
|
-
nvidia_nat_opentelemetry-1.3.
|
12
|
-
nvidia_nat_opentelemetry-1.3.
|
13
|
-
nvidia_nat_opentelemetry-1.3.
|
14
|
-
nvidia_nat_opentelemetry-1.3.
|
11
|
+
nvidia_nat_opentelemetry-1.3.0a20250909.dist-info/METADATA,sha256=YoYxliOOfJsomMgjVwGJz-Rk2dqHPE6Mc5VDDo4_p-E,1733
|
12
|
+
nvidia_nat_opentelemetry-1.3.0a20250909.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
13
|
+
nvidia_nat_opentelemetry-1.3.0a20250909.dist-info/entry_points.txt,sha256=gmEKhCafyibUJLGxbn8luTK0UTgIvV2vAtr4uZ8M85I,72
|
14
|
+
nvidia_nat_opentelemetry-1.3.0a20250909.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
|
15
|
+
nvidia_nat_opentelemetry-1.3.0a20250909.dist-info/RECORD,,
|
File without changes
|
File without changes
|