Skip to content

Conversation

adamantal
Copy link
Contributor

@adamantal adamantal commented Jul 21, 2025

In case the Lambda logs are of plain text format, they are not enriched with the requestId information (link to API reference).

I am well aware that logging in json format is preferred, but I think manually enriching the logs with this attribute can be beneficial in at least two cases:

  • even if the application code logs in json format, static init/teardown of the function may be in plain text format - e.g. an entrypoint that prints out some message which still belongs to the same invocation
  • legacy apps (boring, but also our use case)

Tested internally on some of our Lambdas

@adamantal adamantal requested a review from a team as a code owner July 21, 2025 12:30
Copy link

linux-foundation-easycla bot commented Jul 21, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link
Member

@tylerbenson tylerbenson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a screenshot of what the logs before/after look like?

@adamantal
Copy link
Contributor Author

Sure, here's an example snippet of a Lambda invocation:
Screenshot 2025-07-31 at 16 54 09

You can see some Magnum logs when the invocation starts.

The rest of the observability stack is quite simple honestly. We send logs to Loki's OTLP endpoint, and browse them through Grafana.

We have a few other changes in our internal fork that we'd like to contribute back over time. For example in the screenshot you can see the service_instance_id field. This is not exposed to the Lambda collector from the core Otel SDK by default, so we enrich it manually (which is the equivalent of AWS Cloudwatch log streams).

Let me know if you have any questions. Great project btw

if el.Type == string(telemetryapi.PlatformStart) {
if record, ok := el.Record.(map[string]interface{}); ok {
if requestId, ok := record["requestId"].(string); ok {
r.currentFaasInvocationID = requestId
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not as familiar with this code, but any reason you are not logging the request ID after this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no special reason. I can add a debug level log to this, if it's helpful

@serkan-ozal serkan-ozal merged commit 8170d73 into open-telemetry:main Aug 11, 2025
14 checks passed
@tylerbenson tylerbenson added the go Pull requests that update Go code label Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants