Skip to content

feat(logs): Add Monolog channel to compiled log attributes - #2029

Merged
Litarnus merged 4 commits into
getsentry:masterfrom
melkamar:patch-1
Oct 8, 2026
Merged

Litarnus merged 4 commits into
getsentry:masterfrom
melkamar:patch-1

Conversation

@melkamar

Copy link
Copy Markdown
Contributor

Description

Adds channel name to the log metadata.

The channel is a relevant piece of metadata of a log entry. This change includes the channel in the recorded attributes, but remains backwards compatible and will not overwrite existing extra or context fields named 'channel'.

I considered making this an opt-in configuration of the Handler in the constructor, but since this is backwards compatible, I figured that's not necessary.

@Litarnus

Copy link
Copy Markdown
Collaborator

Hi @melkamar! Can you tell us why you need the channel name in the log attributes? Adding it to every log message would increase the number of bytes per message, so we are a bit reluctant to add it without proper reason

@melkamar

Copy link
Copy Markdown
Contributor Author

@Litarnus sure, the reason is that I may want to filter for messages sent to a certain channel. For example, if some troubleshooting issues related to async processing, I may want to narrow my search to the messenger channel only to see the Symfony messenger logs.

In our application, we use dozens of different channels. I may want to drill down to a specific one. That's what we currently do in Elastic/Kibana and it's very useful. Having the same in Sentry, along with all the other app data, would be great.

I do understand the reluctance of adding data. I also understand that this is truly pointless for use cases where someone uses a single channel (e.g. app) to send the logs to. So, could this be an opt-in?

@Litarnus

Copy link
Copy Markdown
Collaborator

Thanks for the explanation, I can see that it makes a lot of sense to have that option in your setup.

So, could this be an opt-in?

Yes, I think that would be best. I'm happy to review the PR if you change it to opt-in

@melkamar

Copy link
Copy Markdown
Contributor Author

@Litarnus Thanks, I have pushed an update that makes this opt-in

The channel is a relevant piece of metadata of a log entry.

This change adds an option to include the channel in the recorded attributes,
but remains backwards compatible and will not overwrite
existing extra or context fields named 'channel'.

@stayallive stayallive left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, sorry this took a bit 😄

…ibutes()

Add the channel attribute after the existing array_merge instead of as an
extra argument, so the baselined mixed-argument issues still match. Context
and extra still take precedence over the channel.
@Litarnus
Litarnus merged commit 3947405 into getsentry:master Oct 8, 2026
50 checks 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.

3 participants