-
Notifications
You must be signed in to change notification settings - Fork 626
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
Logging: Defensively access provider resource #890
Logging: Defensively access provider resource #890
Conversation
c5ea1f6
to
059eca9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does it mean for something to be defensive?
I guess gracefully downgrade instead of crashing when some condition is not met like using |
059eca9
to
0a8c8f3
Compare
old_factory = logging.getLogRecordFactory() | ||
LoggingInstrumentor._old_factory = old_factory | ||
|
||
service_name = None | ||
|
||
def record_factory(*args, **kwargs): | ||
record = old_factory(*args, **kwargs) | ||
|
||
record.otelSpanID = "0" | ||
record.otelTraceID = "0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably out of scope, what do you think about setting service name to "" here similar to span, traceid and defensively access resource on the below span instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about accessing resource from span as span API does not define resource at all. ReadableSpan defines resource which should only be used by the SDK. I know somewhat similar argument applies to provider but for some reason I feel doing it with provider is a lesser evil. Happy to hear other ideas/counter-arguments but may be we shold open an issue and discuss there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we should discuss it in the next SIG call. Not span vs provider but the fact that an instrumentation depends on an SDK feature which shouldn't be the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the fact that an instrumentation depends on an SDK feature which shouldn't be the case.
Isn't this an exception and I remember there was some discussion around if instrumentation-logging
should actually be an instrumentation. I am not aware of any other instrumentation depending sdk feature.
7215334
to
91ec1a2
Compare
Now service name is extracted from the provider defensively and lazily. This accounts for an SDK that does not provide access to "resource" via TracerProviders and for lazy initialization of TracerProviders. Fixes open-telemetry#810
dea305c
to
6560157
Compare
Description
Now service name is extracted from the provider defensively and lazily.
This accounts for an SDK that does not provide access to "resource" via
TracerProviders and for lazy initialization of TracerProviders.
Fixes #810
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.