nvidia-nat-opentelemetry 1.4.0a20251023__py3-none-any.whl → 1.4.0a20251028__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.

Potentially problematic release.


This version of nvidia-nat-opentelemetry might be problematic. Click here for more details.

@@ -13,11 +13,13 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
+ from nat.plugins.opentelemetry.mixin.otlp_span_exporter_mixin import OTLPProtocol
16
17
  from nat.plugins.opentelemetry.otel_span_exporter import OtelSpanExporter
17
18
  from nat.plugins.opentelemetry.otlp_span_adapter_exporter import OTLPSpanAdapterExporter
18
19
  from nat.plugins.opentelemetry.otlp_span_redaction_adapter_exporter import OTLPSpanHeaderRedactionAdapterExporter
19
20
 
20
21
  __all__ = [
22
+ "OTLPProtocol",
21
23
  "OTLPSpanHeaderRedactionAdapterExporter",
22
24
  "OTLPSpanAdapterExporter",
23
25
  "OtelSpanExporter",
@@ -14,21 +14,25 @@
14
14
  # limitations under the License.
15
15
 
16
16
  import logging
17
+ from typing import Literal
17
18
 
18
19
  from nat.plugins.opentelemetry.otel_span import OtelSpan
19
- from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
20
+ from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter as OTLPSpanExporterGRPC
21
+ from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter as OTLPSpanExporterHTTP
20
22
 
21
23
  logger = logging.getLogger(__name__)
22
24
 
25
+ OTLPProtocol = Literal['http', 'grpc']
26
+
23
27
 
24
28
  class OTLPSpanExporterMixin:
25
29
  """Mixin for OTLP span exporters.
26
30
 
27
31
  This mixin provides OTLP-specific functionality for OpenTelemetry span exporters.
28
- It handles OTLP protocol transmission using the standard OpenTelemetry OTLP HTTP exporter.
32
+ It handles OTLP protocol transmission using the standard OpenTelemetry OTLP exporters.
29
33
 
30
34
  Key Features:
31
- - Standard OTLP HTTP protocol support for span export
35
+ - Standard OTLP HTTP and gRPC protocol support for span export
32
36
  - Configurable endpoint and headers for authentication/routing
33
37
  - Integration with OpenTelemetry's OTLPSpanExporter for reliable transmission
34
38
  - Works with any OTLP-compatible collector or service
@@ -42,16 +46,29 @@ class OTLPSpanExporterMixin:
42
46
  super().__init__(endpoint=endpoint, headers=headers, **kwargs)
43
47
  """
44
48
 
45
- def __init__(self, *args, endpoint: str, headers: dict[str, str] | None = None, **kwargs):
49
+ def __init__(self,
50
+ *args,
51
+ endpoint: str,
52
+ headers: dict[str, str] | None = None,
53
+ protocol: OTLPProtocol = 'http',
54
+ **kwargs):
46
55
  """Initialize the OTLP span exporter.
47
56
 
48
57
  Args:
49
58
  endpoint: OTLP service endpoint URL.
50
59
  headers: HTTP headers for authentication and metadata.
60
+ protocol: Transport protocol to use ('http' or 'grpc'). Defaults to 'http'.
51
61
  """
52
62
  # Initialize exporter before super().__init__() to ensure it's available
53
63
  # if parent class initialization potentially calls export_otel_spans()
54
- self._exporter = OTLPSpanExporter(endpoint=endpoint, headers=headers)
64
+
65
+ if protocol == 'http':
66
+ self._exporter = OTLPSpanExporterHTTP(endpoint=endpoint, headers=headers)
67
+ elif protocol == 'grpc':
68
+ self._exporter = OTLPSpanExporterGRPC(endpoint=endpoint, headers=headers)
69
+ else:
70
+ raise ValueError(f"Invalid protocol: {protocol}")
71
+
55
72
  super().__init__(*args, **kwargs)
56
73
 
57
74
  async def export_otel_spans(self, spans: list[OtelSpan]) -> None:
@@ -16,6 +16,7 @@
16
16
  import logging
17
17
 
18
18
  from nat.builder.context import ContextState
19
+ from nat.plugins.opentelemetry.mixin.otlp_span_exporter_mixin import OTLPProtocol
19
20
  from nat.plugins.opentelemetry.mixin.otlp_span_exporter_mixin import OTLPSpanExporterMixin
20
21
  from nat.plugins.opentelemetry.otel_span_exporter import OtelSpanExporter
21
22
 
@@ -32,7 +33,7 @@ class OTLPSpanAdapterExporter(OTLPSpanExporterMixin, OtelSpanExporter):
32
33
  Key Features:
33
34
  - Complete span processing pipeline (IntermediateStep → Span → OtelSpan → Export)
34
35
  - Batching support for efficient transmission
35
- - OTLP HTTP protocol for maximum compatibility
36
+ - OTLP HTTP and gRPC protocol for maximum compatibility
36
37
  - Configurable authentication via headers
37
38
  - Resource attribute management
38
39
  - Error handling and retry logic
@@ -48,6 +49,7 @@ class OTLPSpanAdapterExporter(OTLPSpanExporterMixin, OtelSpanExporter):
48
49
  exporter = OTLPSpanAdapterExporter(
49
50
  endpoint="https://api.service.com/v1/traces",
50
51
  headers={"Authorization": "Bearer your-token"},
52
+ protocol='http',
51
53
  batch_size=50,
52
54
  flush_interval=10.0
53
55
  )
@@ -67,6 +69,7 @@ class OTLPSpanAdapterExporter(OTLPSpanExporterMixin, OtelSpanExporter):
67
69
  # OTLPSpanExporterMixin args
68
70
  endpoint: str,
69
71
  headers: dict[str, str] | None = None,
72
+ protocol: OTLPProtocol = 'http',
70
73
  **otlp_kwargs):
71
74
  """Initialize the OTLP span exporter.
72
75
 
@@ -80,6 +83,7 @@ class OTLPSpanAdapterExporter(OTLPSpanExporterMixin, OtelSpanExporter):
80
83
  resource_attributes: Additional resource attributes for spans.
81
84
  endpoint: The endpoint for the OTLP service.
82
85
  headers: The headers for the OTLP service.
86
+ protocol: The protocol to use for the OTLP service, default is 'http'.
83
87
  otlp_kwargs: Additional keyword arguments for the OTLP service.
84
88
  """
85
89
  super().__init__(context_state=context_state,
@@ -91,4 +95,5 @@ class OTLPSpanAdapterExporter(OTLPSpanExporterMixin, OtelSpanExporter):
91
95
  resource_attributes=resource_attributes,
92
96
  endpoint=endpoint,
93
97
  headers=headers,
98
+ protocol=protocol,
94
99
  **otlp_kwargs)
@@ -22,6 +22,7 @@ from typing import Any
22
22
  from nat.builder.context import ContextState
23
23
  from nat.observability.processor.redaction import SpanHeaderRedactionProcessor
24
24
  from nat.observability.processor.span_tagging_processor import SpanTaggingProcessor
25
+ from nat.plugins.opentelemetry.mixin.otlp_span_exporter_mixin import OTLPProtocol
25
26
  from nat.plugins.opentelemetry.otlp_span_adapter_exporter import OTLPSpanAdapterExporter
26
27
 
27
28
  logger = logging.getLogger(__name__)
@@ -39,7 +40,7 @@ class OTLPSpanHeaderRedactionAdapterExporter(OTLPSpanAdapterExporter):
39
40
  - Privacy level tagging for compliance and governance
40
41
  - Complete span processing pipeline (IntermediateStep → Span → Redaction → Tagging → OtelSpan → Batching → Export)
41
42
  - Batching support for efficient transmission
42
- - OTLP HTTP protocol for maximum compatibility
43
+ - OTLP HTTP and gRPC protocol for maximum compatibility
43
44
  - Configurable authentication via headers
44
45
  - Resource attribute management
45
46
  - Error handling and retry logic
@@ -63,6 +64,7 @@ class OTLPSpanHeaderRedactionAdapterExporter(OTLPSpanAdapterExporter):
63
64
  exporter = OTLPSpanRedactionAdapterExporter(
64
65
  endpoint="https://api.service.com/v1/traces",
65
66
  headers={"Authorization": "Bearer your-token"},
67
+ protocol='http',
66
68
  redaction_attributes=["user.email", "request.body"],
67
69
  redaction_headers=["x-user-id"],
68
70
  redaction_callback=should_redact,
@@ -96,6 +98,7 @@ class OTLPSpanHeaderRedactionAdapterExporter(OTLPSpanAdapterExporter):
96
98
  # OTLPSpanExporterMixin args
97
99
  endpoint: str,
98
100
  headers: dict[str, str] | None = None,
101
+ protocol: OTLPProtocol = 'http',
99
102
  **otlp_kwargs):
100
103
  """Initialize the OTLP span exporter with redaction and tagging capabilities.
101
104
 
@@ -117,6 +120,7 @@ class OTLPSpanHeaderRedactionAdapterExporter(OTLPSpanAdapterExporter):
117
120
  redaction_tag: Tag to add to spans when redaction occurs.
118
121
  endpoint: The endpoint for the OTLP service.
119
122
  headers: The headers for the OTLP service.
123
+ protocol: The protocol to use for the OTLP service, default is 'http'.
120
124
  otlp_kwargs: Additional keyword arguments for the OTLP service.
121
125
  """
122
126
  super().__init__(context_state=context_state,
@@ -128,6 +132,7 @@ class OTLPSpanHeaderRedactionAdapterExporter(OTLPSpanAdapterExporter):
128
132
  resource_attributes=resource_attributes,
129
133
  endpoint=endpoint,
130
134
  headers=headers,
135
+ protocol=protocol,
131
136
  **otlp_kwargs)
132
137
 
133
138
  # Insert redaction and tagging processors to the front of the processing pipeline
@@ -159,7 +159,8 @@ async def patronus_telemetry_exporter(config: PatronusTelemetryExporter, builder
159
159
  flush_interval=config.flush_interval,
160
160
  max_queue_size=config.max_queue_size,
161
161
  drop_on_overflow=config.drop_on_overflow,
162
- shutdown_timeout=config.shutdown_timeout)
162
+ shutdown_timeout=config.shutdown_timeout,
163
+ protocol="grpc")
163
164
 
164
165
 
165
166
  class GalileoTelemetryExporter(BatchConfigMixin, CollectorConfigMixin, TelemetryExporterBaseConfig, name="galileo"):
@@ -192,3 +193,45 @@ async def galileo_telemetry_exporter(config: GalileoTelemetryExporter, builder:
192
193
  drop_on_overflow=config.drop_on_overflow,
193
194
  shutdown_timeout=config.shutdown_timeout,
194
195
  )
196
+
197
+
198
+ class DBNLTelemetryExporter(BatchConfigMixin, TelemetryExporterBaseConfig, name="dbnl"):
199
+ """A telemetry exporter to transmit traces to DBNL."""
200
+
201
+ api_url: str | None = Field(description="The DBNL API URL.", default=None)
202
+ api_token: str | None = Field(description="The DBNL API token.", default=None)
203
+ project_id: str | None = Field(description="The DBNL project id.", default=None)
204
+
205
+
206
+ @register_telemetry_exporter(config_type=DBNLTelemetryExporter)
207
+ async def dbnl_telemetry_exporter(config: DBNLTelemetryExporter, builder: Builder):
208
+ """Create a DBNL telemetry exporter."""
209
+
210
+ from nat.plugins.opentelemetry import OTLPSpanAdapterExporter
211
+
212
+ api_token = config.api_token or os.environ.get("DBNL_API_TOKEN")
213
+ if not api_token:
214
+ raise ValueError("API token is required for DBNL")
215
+ project_id = config.project_id or os.environ.get("DBNL_PROJECT_ID")
216
+ if not project_id:
217
+ raise ValueError("Project id is required for DBNL")
218
+
219
+ headers = {
220
+ "Authorization": f"Bearer {api_token}",
221
+ "x-dbnl-project-id": project_id,
222
+ }
223
+
224
+ api_url = config.api_url or os.environ.get("DBNL_API_URL")
225
+ if not api_url:
226
+ raise ValueError("API url is required for DBNL")
227
+ endpoint = api_url.rstrip("/") + "/otel/v1/traces"
228
+
229
+ yield OTLPSpanAdapterExporter(
230
+ endpoint=endpoint,
231
+ headers=headers,
232
+ batch_size=config.batch_size,
233
+ flush_interval=config.flush_interval,
234
+ max_queue_size=config.max_queue_size,
235
+ drop_on_overflow=config.drop_on_overflow,
236
+ shutdown_timeout=config.shutdown_timeout,
237
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nvidia-nat-opentelemetry
3
- Version: 1.4.0a20251023
3
+ Version: 1.4.0a20251028
4
4
  Summary: Subpackage for OpenTelemetry integration in NeMo Agent toolkit
5
5
  Author: NVIDIA Corporation
6
6
  Maintainer: NVIDIA Corporation
@@ -16,7 +16,7 @@ Requires-Python: <3.14,>=3.11
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE-3rd-party.txt
18
18
  License-File: LICENSE.md
19
- Requires-Dist: nvidia-nat==v1.4.0a20251023
19
+ Requires-Dist: nvidia-nat==v1.4.0a20251028
20
20
  Requires-Dist: opentelemetry-api~=1.2
21
21
  Requires-Dist: opentelemetry-exporter-otlp~=1.3
22
22
  Requires-Dist: opentelemetry-sdk~=1.3
@@ -0,0 +1,17 @@
1
+ nat/meta/pypi.md,sha256=_o1o1BLPY1pvjCkklWxlm7LlIDMPCk-2Rho85NUuN8U,1109
2
+ nat/plugins/opentelemetry/__init__.py,sha256=6RYrwlYGss4SzyAwjcbgFTLKaLk9jEIHTGEAF8XiC5E,1181
3
+ nat/plugins/opentelemetry/otel_span.py,sha256=MC_ROZ8gSTu0gxRaaz77UDbn1ouZTZP3N_-0PcN140U,16564
4
+ nat/plugins/opentelemetry/otel_span_exporter.py,sha256=YO7JsQgi8Cf2OQBJ_s78HwJjrWx9SdqMvPen3Pa2_bI,6533
5
+ nat/plugins/opentelemetry/otlp_span_adapter_exporter.py,sha256=cWBfPKHET7U1oRMs1QMXvg-z1c1DaqYrLzHIyUUbfGM,4237
6
+ nat/plugins/opentelemetry/otlp_span_redaction_adapter_exporter.py,sha256=YnoQlktT6EJRM7o8bhvYQcdGrAdOXNEk8wOimK_Wy88,7509
7
+ nat/plugins/opentelemetry/register.py,sha256=u3Hq5mhnDfYn4Q-XkKCGr13xuM6SpS8d3OhroTUjiCc,10711
8
+ nat/plugins/opentelemetry/span_converter.py,sha256=Gz3KvRNQeEBBlpaPO8YRAJkw4fmzV7m9bT6dGX0IV2E,8846
9
+ nat/plugins/opentelemetry/mixin/__init__.py,sha256=Xs1JQ16L9btwreh4pdGKwskffAw1YFO48jKrU4ib_7c,685
10
+ nat/plugins/opentelemetry/mixin/otlp_span_exporter_mixin.py,sha256=BN8fRHHEHEWZyrYoudl9lSeH--I2RY2dJVPyWIgDB0I,3454
11
+ nvidia_nat_opentelemetry-1.4.0a20251028.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
12
+ nvidia_nat_opentelemetry-1.4.0a20251028.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
13
+ nvidia_nat_opentelemetry-1.4.0a20251028.dist-info/METADATA,sha256=joY4cSLPTHUKhnqu_R6sv3tItHbyM5VAd3rVBkTKikc,2039
14
+ nvidia_nat_opentelemetry-1.4.0a20251028.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ nvidia_nat_opentelemetry-1.4.0a20251028.dist-info/entry_points.txt,sha256=gmEKhCafyibUJLGxbn8luTK0UTgIvV2vAtr4uZ8M85I,72
16
+ nvidia_nat_opentelemetry-1.4.0a20251028.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
17
+ nvidia_nat_opentelemetry-1.4.0a20251028.dist-info/RECORD,,
@@ -1,17 +0,0 @@
1
- nat/meta/pypi.md,sha256=_o1o1BLPY1pvjCkklWxlm7LlIDMPCk-2Rho85NUuN8U,1109
2
- nat/plugins/opentelemetry/__init__.py,sha256=j-YKuxwSIzGziyDyunw8s_W7WiFiqKLdFjw-utwHPFk,1079
3
- nat/plugins/opentelemetry/otel_span.py,sha256=MC_ROZ8gSTu0gxRaaz77UDbn1ouZTZP3N_-0PcN140U,16564
4
- nat/plugins/opentelemetry/otel_span_exporter.py,sha256=YO7JsQgi8Cf2OQBJ_s78HwJjrWx9SdqMvPen3Pa2_bI,6533
5
- nat/plugins/opentelemetry/otlp_span_adapter_exporter.py,sha256=6xQHkKDhQk3-kObqj6kRv8ZlJtIV2Qqox6YkY0PCOYs,3945
6
- nat/plugins/opentelemetry/otlp_span_redaction_adapter_exporter.py,sha256=qRrUIxYRlCDaAkEGlFTaEkCJCsb68GBo11EGEiE6S8E,7217
7
- nat/plugins/opentelemetry/register.py,sha256=KnhV-axY0kJzZ3RReG4e_mTFR1dMr7d3a6ysYiCLTUI,9063
8
- nat/plugins/opentelemetry/span_converter.py,sha256=Gz3KvRNQeEBBlpaPO8YRAJkw4fmzV7m9bT6dGX0IV2E,8846
9
- nat/plugins/opentelemetry/mixin/__init__.py,sha256=Xs1JQ16L9btwreh4pdGKwskffAw1YFO48jKrU4ib_7c,685
10
- nat/plugins/opentelemetry/mixin/otlp_span_exporter_mixin.py,sha256=3vK6DkTJXp6ZFH3AgNYUuuMOzjyskh_nVUWK-qMYKzM,2809
11
- nvidia_nat_opentelemetry-1.4.0a20251023.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
12
- nvidia_nat_opentelemetry-1.4.0a20251023.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
13
- nvidia_nat_opentelemetry-1.4.0a20251023.dist-info/METADATA,sha256=R7MWQaHgT0BaJAM_fGZ0JL3NP5sC4MUrPcOtEiwzvcQ,2039
14
- nvidia_nat_opentelemetry-1.4.0a20251023.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- nvidia_nat_opentelemetry-1.4.0a20251023.dist-info/entry_points.txt,sha256=gmEKhCafyibUJLGxbn8luTK0UTgIvV2vAtr4uZ8M85I,72
16
- nvidia_nat_opentelemetry-1.4.0a20251023.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
17
- nvidia_nat_opentelemetry-1.4.0a20251023.dist-info/RECORD,,