Skip to content
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

bug: merge the logRecord resources with those provided by the logProvider #21

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

def
Copy link
Contributor

@def def commented Oct 12, 2023

This PR enables customizing the resource attributes for any emitted logRecord.

In our specific use case, our monitoring agent collects logs of every container running on a node and subsequently sends these logs to the OpenTelemetry collector. Therefore, we need to set the container.id and service.name resource attributes for each log entry emitted.

@def def requested a review from chameleon82 as a code owner October 12, 2023 09:17
@@ -40,7 +40,10 @@ func (l logger) Emit(logRecord logs.LogRecord) {
return
}

pr := l.provider.resource
pr, err := resource.Merge(l.provider.resource, logRecord.Resource())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the suggestion.

That sound more to be a Scope Resource and we have it defined in proto and model.
and correct implementation should be

pr, err := logRecord.Resource()

But from this point provider resource lost and should be taken in LogRecordProcessor implementation. However,
we don't have another way yet to access LoggerProvider resources in the Exporter

I will merge that MR to have both resources merged as currently logs is not getting grouped by resource/scope when sent to OTLP, but this should be refactored in the future.

@chameleon82 chameleon82 changed the title Merge the logRecord resources with those provided by the logProvider bug: merge the logRecord resources with those provided by the logProvider Oct 13, 2023
@chameleon82 chameleon82 merged commit c31bc41 into agoda-com:master Oct 13, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants