-
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
Guðmundur Björn Birkisson
committed
Jan 24, 2024
1 parent
1c22963
commit ef7038b
Showing
7 changed files
with
65 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,33 @@ | ||
import os | ||
from typing import Any | ||
|
||
import ddtrace | ||
|
||
from ._enums import Exporter, ExporterType | ||
from ._exporter import Exporter, ExporterType | ||
from ._writer import OTELWriter | ||
|
||
__all__ = ["Exporter", "ExporterType"] | ||
|
||
_env_host = os.environ.get("OTEL_TRACE_HOST", "localhost") | ||
_env_port = os.environ.get("OTEL_TRACE_PORT", "4318") | ||
|
||
|
||
def configure_tracer( | ||
*, | ||
enabled: bool, | ||
endpoint: str, | ||
service_name: str, | ||
exporter: Exporter = Exporter( | ||
endpoint=f"http://{_env_host}:{_env_port}", exporter_type=ExporterType.HTTP | ||
), | ||
resource_attributes: dict[str, Any] | None = None, | ||
exporter: Exporter = Exporter.HTTP, | ||
) -> None: | ||
"""Configure ddtrace to write traces to the otel tracing backend.""" | ||
|
||
# Initialize our custom writer used to handle ddtrace spans. | ||
writer = OTELWriter( | ||
service_name=service_name, | ||
resource_attributes=resource_attributes, | ||
endpoint=endpoint, | ||
exporter=exporter, | ||
resource_attributes=resource_attributes, | ||
) | ||
|
||
ddtrace.tracer.configure(writer=writer, enabled=enabled) |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
from enum import Enum | ||
|
||
|
||
class ExporterType(Enum): | ||
HTTP = "http" | ||
GRPC = "grpc" | ||
|
||
|
||
class Exporter: | ||
def __init__( | ||
self, | ||
*, | ||
endpoint: str, | ||
exporter_type: ExporterType, | ||
headers: dict[str, str] | None = None, | ||
) -> None: | ||
self.endpoint = endpoint | ||
self.exporter_type = exporter_type | ||
self.headers = headers |
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