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

Monolog integration adds "channel" attribute to every log record #1049

Closed
tigrannajaryan opened this issue Jun 22, 2023 · 3 comments · Fixed by open-telemetry/opentelemetry-php-contrib#174
Labels
question Further information is requested signal:logging Related to logging signal tc-review technical committee review feedback

Comments

@tigrannajaryan
Copy link
Member

I am evaluating the monolog integration. I used the following code:

$handler = new \OpenTelemetry\Contrib\Logs\Monolog\Handler(
    $loggerProvider,
    \Psr\Log\LogLevel::INFO,
);
$logger = new \Monolog\Logger('example', [$handler]);

$logger->info('hello, world');
$logger->error('oh no', [
    'foo' => 'bar',
    'exception' => new \Exception('something went wrong'),
]);

Every log record created has an attribute channel that is set equal to Monolog's channel. I wonder if this is a desirable approach.

Should we instead set the Scope name to Monolog's channel instead of adding it to every attribute? The definition of Monolog's channel is the following:

Channels are a great way to identify to which part of the application a record is related.

I think this nicely fits our definition of Scope:

A logical unit of the application code with which the emitted telemetry can be associated.

We currently set Scope's name to "monolog". I think this is a useful information, but perhaps instead of recording as the Scope name we can record it as a Scope attribute (attribute name TBD, need to create an issue in semconv repo).

Alternatively, if we think Scope's name should really be tied to the instrumentation name then I think we should at the very least use the fully qualified "opentelemetry-logger-monolog". In that case we should record the channel name as an attribute, but we need a proper semantic convention (file an issue in semconv repo to decide on the name), I don't think using just channel as the attribute name works (attribute naming rules require attributes to be in namespaces).

@open-telemetry/specs-logs-approvers what do you think? Should log integrations set integration's name as the Scope name (e.g. "monolog" in this case) or should they use the corresponding equivalent concept from the integrated library as the Scope name (the monolog's Channel concept in this case matches our Scope Name concept).

@tigrannajaryan
Copy link
Member Author

I created an issue in the spec to discuss since it is not limited to PHP: open-telemetry/opentelemetry-specification#3562

@brettmc
Copy link
Collaborator

brettmc commented Jun 27, 2023

It sounds like using the channel attribute as the scope name is what's expected, so I've done that in the referenced PR.

@tigrannajaryan
Copy link
Member Author

FYI, spec PR merged: open-telemetry/opentelemetry-specification#3583

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested signal:logging Related to logging signal tc-review technical committee review feedback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants