-
Notifications
You must be signed in to change notification settings - Fork 870
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
Add service.name
to MDC
#9297
Comments
This is something that is currently (sort of) available in the Splunk distro -- it's done in a bit hacky way, where we copy resource attributes over to system properties: https://github.com/signalfx/splunk-otel-java/blob/main/custom/src/main/java/com/splunk/opentelemetry/resource/ResourceAttributesToSystemProperties.java @open-telemetry/java-instrumentation-maintainers we wouldn't mind upstreaming feature over to this repo, if there's a broader interest here. (Of course, not as a sysprop hack: I believe if we were to do that we would add configuration setting for a list of resource attribute keys that are to be captured as part of MDC/ThreadContext) |
sgtm 👍 |
I'll like to take this one. |
@mateuszrzeszutek Where would be a good place to add this implementation? It looks like the implementation will need to be able to access the |
To the MDC/ThreadContext modules, e.g.
Yep -- I think we'll need to add a new |
@mateuszrzeszutek Struggling to find a way to access the |
@cleverchuk In package io.opentelemetry.sdk.autoconfigure;
import io.opentelemetry.sdk.resources.Resource;
public final class SdkAutoconfigureAccess {
public static Resource getResource(AutoConfiguredOpenTelemetrySdk sdk) {
return sdk.getResource();
}
private SdkAutoconfigureAccess() {}
} in private static void setResourceAttributes(AutoConfiguredOpenTelemetrySdk autoConfiguredSdk) {
Resource resource = SdkAutoconfigureAccess.getResource(autoConfiguredSdk);
// add ResourceAttributesHolder to javaagent-bootstrap module. you'll probably have to convert Attributes -> Map<String, String> somewhere
ResourceAttributesHolder.setAttributes(resource.getAttributes());
} call this method in |
@laurit @mateuszrzeszutek |
It looks like it should be a fork |
…ation.mdc.resource-attributes` that will be used to configure `Resource` attributes to be added to logging map diagnostic context.
…ation.mdc.resource-attributes` that will be used to configure `Resource` attributes to be added to logging map diagnostic context.
…ation.mdc.resource-attributes` that will be used to configure `Resource` attributes to be added to logging map diagnostic context.
@laurit please can you take a look at the draft PR at your convenience. How do I make the failing tests pass? |
…ation.mdc.resource-attributes` that will be used to configure `Resource` attributes to be added to logging map diagnostic context.
…ation.mdc.resource-attributes` that will be used to configure `Resource` attributes to be added to logging map diagnostic context.
…ation.mdc.resource-attributes` that will be used to configure `Resource` attributes to be added to logging map diagnostic context.
- use assertJ for unit test assertions - use plural for method and field names - add compile only dependency on `:javaagent-bootstrap` for `instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:library-autoconfigure`
…ation.mdc.resource-attributes` that will be used to configure `Resource` attributes to be added to logging map diagnostic context.
- use assertJ for unit test assertions - use plural for method and field names - add compile only dependency on `:javaagent-bootstrap` for `instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:library-autoconfigure`
- use implementation dependency on `:javaagent-bootstrap`
- use compile dependency on `:javaagent-bootstrap` and do runtime check before use.
- use compile dependency on `:javaagent-bootstrap` and do runtime check before use.
- use compile dependency on `:javaagent-bootstrap` and do runtime check before use.
…ation.mdc.resource-attributes` that will be used to configure `Resource` attributes to be added to logging map diagnostic context.
- use assertJ for unit test assertions - use plural for method and field names - add compile only dependency on `:javaagent-bootstrap` for `instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:library-autoconfigure`
- use implementation dependency on `:javaagent-bootstrap`
- use compile dependency on `:javaagent-bootstrap` and do runtime check before use.
…ation.mdc.resource-attributes` that will be used to configure `Resource` attributes to be added to logging map diagnostic context.
- use assertJ for unit test assertions - use plural for method and field names - add compile only dependency on `:javaagent-bootstrap` for `instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:library-autoconfigure`
- use implementation dependency on `:javaagent-bootstrap`
- use compile dependency on `:javaagent-bootstrap` and do runtime check before use.
- refactor constructor to static method
- move ConfiguredResourceAttributesHolder to javaagent-extension-api
…ation.mdc.resource-attributes` that will be used to configure `Resource` attributes to be added to logging map diagnostic context.
- use assertJ for unit test assertions - use plural for method and field names - add compile only dependency on `:javaagent-bootstrap` for `instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:library-autoconfigure`
- use implementation dependency on `:javaagent-bootstrap`
- use compile dependency on `:javaagent-bootstrap` and do runtime check before use.
- refactor constructor to static method
- move ConfiguredResourceAttributesHolder to javaagent-extension-api
…ation.mdc.resource-attributes` that will be used to configure `Resource` attributes to be added to logging map diagnostic context.
- use assertJ for unit test assertions - use plural for method and field names - add compile only dependency on `:javaagent-bootstrap` for `instrumentation:log4j:log4j-context-data:log4j-context-data-2.17:library-autoconfigure`
- use implementation dependency on `:javaagent-bootstrap`
- use compile dependency on `:javaagent-bootstrap` and do runtime check before use.
- refactor constructor to static method
- move ConfiguredResourceAttributesHolder to javaagent-extension-api
Is your feature request related to a problem? Please describe.
Currently,
trace_id
,trace_flags
andspan_id
are added to MDC, however theservice.name
is not. This attribute is needed as well to tie the logs to the service that generated the logs. The current solution only allows tying them to a trace.Describe the solution you'd like
Add
service.name
to the MDC so that it can be accessible to loggers.Describe alternatives you've considered
Accept logs via the OTLP. This assumes that the system speaks OTLP natively which is not the case.
Additional context
Ability to correlate logs exported via non-OTLP to service. The logs are exported by reading the log file.
The text was updated successfully, but these errors were encountered: