-
Notifications
You must be signed in to change notification settings - Fork 469
chore(otel): collect telemetry for log configs #14409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4ef1fc9
fix telemetry and disable log injection
mabdinur 5d5e2c2
collect config telemetry
mabdinur f5800b8
Merge branch 'main' into munir/otel-logs-poc-follow-up
mabdinur 4268dd9
fix otlp default
mabdinur 6869abe
fix header
mabdinur 831b03b
fmt
mabdinur 4dea1d2
fix debug logs
mabdinur 26b821c
fix telemetry
mabdinur 95ae515
Merge branch 'main' into munir/otel-logs-poc-follow-up
mabdinur 363acb9
default value for logs endpoint is endpoint
mabdinur 639bc53
fix config tests
mabdinur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,21 +1,69 @@ | ||
| import typing as t | ||
|
|
||
| from ddtrace.internal.telemetry import get_config | ||
| from ddtrace.internal.telemetry import report_configuration | ||
| from ddtrace.settings._agent import get_agent_hostname | ||
| from ddtrace.settings._core import DDConfig | ||
|
|
||
|
|
||
| class OpenTelemetryExporterConfig(DDConfig): | ||
| __prefix__ = "otel.exporter" | ||
| def _derive_endpoint(config: "ExporterConfig"): | ||
| if config.PROTOCOL.lower() in ("http/json", "http/protobuf"): | ||
| default_endpoint = ( | ||
| f"http://{get_agent_hostname()}:{ExporterConfig.HTTP_PORT}{ExporterConfig.HTTP_LOGS_ENDPOINT}" | ||
| ) | ||
| else: | ||
| default_endpoint = f"http://{get_agent_hostname()}:{ExporterConfig.GRPC_PORT}" | ||
| return get_config("OTEL_EXPORTER_OTLP_ENDPOINT", default_endpoint) | ||
|
|
||
| # OTLP exporter configuration | ||
| OTLP_PROTOCOL = DDConfig.v(t.Optional[str], "otlp.protocol", default=None) | ||
| OTLP_LOGS_PROTOCOL = DDConfig.v(t.Optional[str], "otlp.logs.protocol", default=None) | ||
| OTLP_ENDPOINT = DDConfig.v(t.Optional[str], "otlp.endpoint", default=None) | ||
| OTLP_LOGS_ENDPOINT = DDConfig.v(t.Optional[str], "otlp.logs.endpoint", default=None) | ||
| OTLP_HEADERS = DDConfig.v(t.Optional[str], "otlp.headers", default=None) | ||
| OTLP_LOGS_HEADERS = DDConfig.v(t.Optional[str], "otlp.logs.headers", default=None) | ||
|
|
||
| def _derive_logs_endpoint(config: "ExporterConfig"): | ||
| if config.LOGS_PROTOCOL.lower() in ("http/json", "http/protobuf"): | ||
| default_endpoint = ( | ||
| f"http://{get_agent_hostname()}:{ExporterConfig.HTTP_PORT}{ExporterConfig.HTTP_LOGS_ENDPOINT}" | ||
| ) | ||
| else: | ||
| default_endpoint = f"http://{get_agent_hostname()}:{ExporterConfig.GRPC_PORT}" | ||
| return get_config(["OTEL_EXPORTER_OTLP_LOGS_ENDPOINT", "OTEL_EXPORTER_OTLP_ENDPOINT"], default_endpoint) | ||
|
|
||
| exporter_config = OpenTelemetryExporterConfig() | ||
|
|
||
| report_configuration(exporter_config) | ||
| def _derive_logs_protocol(config: "ExporterConfig"): | ||
| return get_config("OTEL_EXPORTER_OTLP_LOGS_PROTOCOL", config.PROTOCOL) | ||
|
|
||
|
|
||
| def _derive_logs_headers(config: "ExporterConfig"): | ||
| return get_config("OTEL_EXPORTER_OTLP_LOGS_HEADERS", config.HEADERS) | ||
|
|
||
|
|
||
| def _derive_logs_timeout(config: "ExporterConfig"): | ||
| return get_config("OTEL_EXPORTER_OTLP_LOGS_TIMEOUT", config.DEFAULT_TIMEOUT, int) | ||
|
|
||
|
|
||
| class OpenTelemetryConfig(DDConfig): | ||
| __prefix__ = "otel" | ||
|
|
||
|
|
||
| class ExporterConfig(DDConfig): | ||
| __prefix__ = "exporter" | ||
|
|
||
| GRPC_PORT: int = 4317 | ||
| HTTP_PORT: int = 4318 | ||
| HTTP_LOGS_ENDPOINT: str = "/v1/logs" | ||
| DEFAULT_HEADERS: str = "" | ||
| DEFAULT_TIMEOUT: int = 10000 | ||
|
|
||
| PROTOCOL = DDConfig.v(t.Optional[str], "otlp.protocol", default="grpc") | ||
| ENDPOINT = DDConfig.d(str, _derive_endpoint) | ||
| HEADERS = DDConfig.v(str, "otlp.headers", default=DEFAULT_HEADERS) | ||
| TIMEOUT = DDConfig.v(int, "otlp.timeout", default=DEFAULT_TIMEOUT) | ||
|
|
||
| LOGS_PROTOCOL = DDConfig.d(str, _derive_logs_protocol) | ||
| LOGS_ENDPOINT = DDConfig.d(str, _derive_logs_endpoint) | ||
| LOGS_HEADERS = DDConfig.d(str, _derive_logs_headers) | ||
| LOGS_TIMEOUT = DDConfig.d(int, _derive_logs_timeout) | ||
|
|
||
|
|
||
| OpenTelemetryConfig.include(ExporterConfig, namespace="exporter") | ||
|
|
||
| otel_config = OpenTelemetryConfig() | ||
|
|
||
| report_configuration(otel_config) |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.