|
4 | 4 | import os
|
5 | 5 | import socket
|
6 | 6 | from logging import Logger, getLogger
|
7 |
| -from typing import Dict, Optional, Sequence, Tuple |
| 7 | +from typing import Optional, Sequence, Tuple |
8 | 8 |
|
9 | 9 | from typing_extensions import override
|
10 | 10 |
|
11 |
| -from opentelemetry.exporter.otlp.proto.common.metrics_encoder import encode_metrics |
12 | 11 | from opentelemetry.exporter.otlp.proto.common.trace_encoder import encode_spans
|
13 |
| -from opentelemetry.sdk.metrics._internal.aggregation import AggregationTemporality |
14 |
| -from opentelemetry.sdk.metrics._internal.export import MetricExportResult |
15 |
| -from opentelemetry.sdk.metrics._internal.point import MetricsData |
16 |
| -from opentelemetry.sdk.metrics.export import MetricExporter |
17 |
| -from opentelemetry.sdk.metrics.view import Aggregation |
18 | 12 | from opentelemetry.sdk.trace import ReadableSpan
|
19 | 13 | from opentelemetry.sdk.trace.export import SpanExporter, SpanExportResult
|
20 | 14 |
|
21 | 15 | DEFAULT_ENDPOINT = "127.0.0.1:2000"
|
22 | 16 | PROTOCOL_HEADER = '{"format":"json","version":1}\n'
|
23 |
| -FORMAT_OTEL_METRICS_BINARY_PREFIX = "M1" |
24 | 17 |
|
25 | 18 | FORMAT_OTEL_SAMPLED_TRACES_BINARY_PREFIX = "T1S"
|
26 | 19 | FORMAT_OTEL_UNSAMPLED_TRACES_BINARY_PREFIX = "T1U"
|
@@ -66,44 +59,6 @@ def _parse_endpoint(self, endpoint: str) -> Tuple[str, int]:
|
66 | 59 | return host, port
|
67 | 60 |
|
68 | 61 |
|
69 |
| -class OTLPUdpMetricExporter(MetricExporter): |
70 |
| - def __init__( |
71 |
| - self, |
72 |
| - endpoint: Optional[str] = None, |
73 |
| - preferred_temporality: Dict[type, AggregationTemporality] = None, |
74 |
| - preferred_aggregation: Dict[type, Aggregation] = None, |
75 |
| - ): |
76 |
| - super().__init__( |
77 |
| - preferred_temporality=preferred_temporality, |
78 |
| - preferred_aggregation=preferred_aggregation, |
79 |
| - ) |
80 |
| - self._udp_exporter = UdpExporter(endpoint=endpoint) |
81 |
| - |
82 |
| - @override |
83 |
| - def export( |
84 |
| - self, |
85 |
| - metrics_data: MetricsData, |
86 |
| - timeout_millis: float = 10_000, |
87 |
| - **kwargs, |
88 |
| - ) -> MetricExportResult: |
89 |
| - serialized_data = encode_metrics(metrics_data).SerializeToString() |
90 |
| - |
91 |
| - try: |
92 |
| - self._udp_exporter.send_data(data=serialized_data, signal_format_prefix=FORMAT_OTEL_METRICS_BINARY_PREFIX) |
93 |
| - return MetricExportResult.SUCCESS |
94 |
| - except Exception as exc: # pylint: disable=broad-except |
95 |
| - _logger.error("Error exporting metrics: %s", exc) |
96 |
| - return MetricExportResult.FAILURE |
97 |
| - |
98 |
| - # pylint: disable=no-self-use |
99 |
| - def force_flush(self, timeout_millis: float = 10_000) -> bool: |
100 |
| - # TODO: implement force flush |
101 |
| - return True |
102 |
| - |
103 |
| - def shutdown(self, timeout_millis: float = 30_000, **kwargs) -> None: |
104 |
| - self._udp_exporter.shutdown() |
105 |
| - |
106 |
| - |
107 | 62 | class OTLPUdpSpanExporter(SpanExporter):
|
108 | 63 | def __init__(self, endpoint: Optional[str] = None, sampled: bool = True):
|
109 | 64 | self._udp_exporter = UdpExporter(endpoint=endpoint)
|
|
0 commit comments