Skip to content

Commit

Permalink
[exporter/datadogexporter] Add support for custom log source (#35051)
Browse files Browse the repository at this point in the history
**Description:**
This PR updates
`github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/exporter/logsagentexporter`
to include commit:
DataDog/datadog-agent@09b07eb.
This adds support for setting a custom log source from resource
attribute or log attribute `datadog.log.source`.


**Link to tracking Issue:** <Issue number if applicable>

**Testing:** Tested this locally by sending logs with attribute
`datadog.log.source` and ensuring this was used as the source.

**Documentation:** Updated datadog exporter README.
  • Loading branch information
mackjmr authored Sep 9, 2024
1 parent 0ceefaa commit b3e952f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .chloggen/mackjmr_custom-log-src-support.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: datadogexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add support for setting a custom log source from resource attribute `datadog.log.source`

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [35051]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
14 changes: 14 additions & 0 deletions exporter/datadogexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,17 @@ To get the service field correctly populated in your logs, you can specify servi
[alpha]:https://github.com/open-telemetry/opentelemetry-collector#alpha
[contrib]:https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
[AWS]:https://aws-otel.github.io/docs/partners/datadog

### How to add custom log source

In order to add a custom source to your OTLP logs, set resource attribute `datadog.log.source`. This feature requires `exporter.datadogexporter.UseLogsAgentExporter` feature flag to be enabled (now enabled by default).

Example:
```
processors:
transform/logs:
log_statements:
- context: resource
statements:
- set(attributes["datadog.log.source"], "otel")
```

0 comments on commit b3e952f

Please sign in to comment.