Skip to content

feat: Dash0 telemetry provider - #1228

Merged
seb-cr merged 6 commits into
masterfrom
ENG-5107/add-dash0-telemetry
Sep 23, 2026
Merged

seb-cr merged 6 commits into
masterfrom
ENG-5107/add-dash0-telemetry

Conversation

@seb-cr

@seb-cr seb-cr commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Logger events (errors and metrics) will be sent to Dash0 from functions that are configured with Dash0's Lambda Extension layer.

Contrary to existing telemetry providers, I have made @opentelemetry/api an optional peer dependency rather than a runtime dependency. Projects that use Dash0 will need to explicitly add it to their dependencies. This avoids having the package installed if your project is not using Dash0. In the next major release, this will be the standard for all telemetry providers.

Jira: ENG-5107

@curlyfriesplease

Copy link
Copy Markdown

Looks good I think. Regarding testing I guess just something that calls trace.getActiveSpan() to examine the OTEL span would be sufficient, right?

Spreading an `Error` will not copy the "main" error properties, namely
`name`, `message` and `stack`. To ensure they are recorded in the
exception, include them explicitly.

The error is still spread into the exception object to ensure we record
any additional properties, for example `code`.
@seb-cr

seb-cr commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Notes from testing:

  • OpenTelemetry doesn't force specific attribute keys, but there are semantic conventions. For example, Lambda spans should have a faas.invocation_id attribute, HTTP spans should have http.route, client.address, etc. All these are generated for us by the Dash0 Lambda Extension.

    On previous platforms, we've had the label and metric namespace to ourselves and not worried about which keys we use. To avoid risk of conflicting attribute keys in the OTel world, we could prefix all keys with something like custom.. After consideration though, I think this is best left to the application rather than mandated by Lambda Wrapper. We may want to follow the semantic conventions in the future, and we would need keys to be unmodified.

  • Dash0 also automatically generates events for certain kinds of exception. These include 4xx and 5xx HTTP responses and the overall Lambda response (for API Gateway-triggered invocations). Nothing to do with Lambda Wrapper, but interesting to note, and may mean we encounter some duplication of error events where we log them ourselves. We should continue to log all errors ourselves – the generated exceptions have no stack trace.

  • The error log message from LoggerService#error includes an empty message body unless the optional message parameter is used. This makes it hard to see error details in the logs because Dash0 shows only the (empty) body. The error log metadata gets turned into a log attribute, which is visible but needs extra clicks. Needs fixing in a separate PR. (edit: fix: Use error message as log message if none provided #1229)

  • Error details recorded from LoggerService#error are incomplete. Only the message is visible in the exception event. This was caused by the spread operator not behaving as expected on Error instances. Fixed in 2a030b1.

Always use the error message. Also avoids the trouble of cloning the
error in order to override its message.
@seb-cr

seb-cr commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Following on from the previous fix: I think we should consider the purpose between an error's log message (optional argument passed into LoggerService#error) and the error message (message property of an error). The log message should tell us what went wrong, e.g. "couldn't create record". The error message should tell us the technical cause, e.g. "request failed with status code 400". The former should go into the log, while latter is the message that should be recorded in the exception.

In 61349f1 I've therefore removed the use of message in Dash0Telemetry#error, which then also removes the need to clone the error object.

@curlyfriesplease

Copy link
Copy Markdown

Following on from the previous fix: I think we should consider the purpose between an error's log message (optional argument passed into LoggerService#error) and the error message (message property of an error). The log message should tell us what went wrong, e.g. "couldn't create record". The error message should tell us the technical cause, e.g. "request failed with status code 400". The former should go into the log, while latter is the message that should be recorded in the exception.

In 61349f1 I've therefore removed the use of message in Dash0Telemetry#error, which then also removes the need to clone the error object.

Thanks for clarifying this point.

@seb-cr
seb-cr merged commit d7d2ec1 into master Sep 23, 2026
6 checks passed
@seb-cr
seb-cr deleted the ENG-5107/add-dash0-telemetry branch September 23, 2026 13:24
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

seb-cr added a commit that referenced this pull request Sep 24, 2026
This fixes a bug in our error logging that I noticed while working on
#1228. If the `message` parameter of `Logger#error` is omitted, an empty
message is logged:

```jsonc
{
  "level": "error",
  "message": "",
  "error": { /* ... */ }
}
```

This previously went unnoticed because the Lumigo error integration also
writes to the logs and was extracting `error.message`, so both were
visible, albeit in separate log messages.

When no error log message is specified, we should fall back to using
`error.message`.

Jira: [ENG-5363]

[ENG-5363]: https://comicrelief.atlassian.net/browse/ENG-5363
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants