forked from sodadata/soda-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
91 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import logging | ||
from typing import Dict, Sequence, Optional | ||
|
||
from opentelemetry.sdk.trace.export import ( | ||
ConsoleSpanExporter, | ||
SpanExportResult, | ||
) | ||
from opentelemetry.sdk.trace import ReadableSpan | ||
from opentelemetry.exporter.otlp.proto.http import Compression | ||
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def get_soda_spans(spans: Sequence[ReadableSpan]) -> Sequence[ReadableSpan]: | ||
result = [] | ||
for span in spans: | ||
if span.name.startswith("soda"): | ||
result.append(span) | ||
else: | ||
logger.debug(f"Open Telemetry: Skipping non-soda span '{span.name}'.") | ||
|
||
return result | ||
|
||
|
||
class SodaConsoleSpanExporter(ConsoleSpanExporter): | ||
"""Soda version of console exporter. | ||
Does not export any non-soda spans for security and privacy reasons.""" | ||
def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult: | ||
return super().export(get_soda_spans(spans)) | ||
|
||
|
||
class SodaOTLPSpanExporter(OTLPSpanExporter): | ||
"""Soda version of OTLP exporter. | ||
Does not export any non-soda spans for security and privacy reasons.""" | ||
def __init__( | ||
self, | ||
endpoint: Optional[str] = None, | ||
certificate_file: Optional[str] = None, | ||
headers: Optional[Dict[str, str]] = None, | ||
timeout: Optional[int] = None, | ||
compression: Optional[Compression] = None, | ||
): | ||
super().__init__( | ||
endpoint, | ||
certificate_file, | ||
headers, | ||
timeout, | ||
compression, | ||
) | ||
|
||
def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult: | ||
return super().export(get_soda_spans(spans)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters