-
Notifications
You must be signed in to change notification settings - Fork 855
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
Make it impossible to remove mandatory resource attributes that the SDK has defaults for #5595
Comments
Disagree that this is a bug. If a user explicitly replaces the entire resource, they should 100% be allowed to do that. |
I think I disagree a little, I think users should not be easily (if at all) do things that is clearly against the specs, assuming the Telemetry SDK SemConv specs are applicable to the OTel Java SDK:
Here (as a user), it is pretty unexpected to me that I need to manually add back the mandatory attributes if I want to add mines. I don't think this is a good user experience, this should be possible without me (the user) knowing about those default attributes. |
I wouldn't say that the |
I think it is more about |
We talked about this and there seemed to be agreement in extending the Coincidentally, @parth1601 has opened PR #5619 which does just this, albeit with a different end goal in mind. Goal of #5619 is to make it easy to customize the resource of one signal's resource when using autoconfigure (which I don't recommend). |
I belief this is resolved. Now that #5619 is merged, its more challenging to remove the default resource attributes. |
So how do you remove the default, but non-mandatory resources? I am an end user of the opentelemetry SDK. I got it to work but there is a lot of noise collected in my backend. like the telemetry.sdk.* attributes. I want them gone. I'm not interested in a righteous debate. I just need sample code. Let me deal with the consequences of my actions myself, I'm a grownup. Could the documentation provide an example? |
hi @drok! did you see @jack-berg's #5595 (comment) above?
|
Hi @trask! I certainly saw jack-berg's comment, and the merged branch that implements the However, it remains that as an (new to opentelemetry, and telemetry) end user, I'm seeing unwanted strings sent to my backend, and I'm not yet able to figure out how to implement the let traceExporter = new OTLPTraceExporter({ url: 'http://192.168.20.152:4318/v1/traces' });
this.sdk = new optl.NodeSDK({
traceExporter,
instrumentations: [],
resourceDetectors: [],
autoDetectResources: false,
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: extensionContext.extension.packageJSON.name,
[SemanticResourceAttributes.SERVICE_VERSION]: extensionContext.extension.packageJSON.version,
[SemanticResourceAttributes.SERVICE_NAMESPACE]:
(env.appName == "Visual Studio Code" ? "vscode" : env.appName) + "." + env.appHost,
[SemanticResourceAttributes.SERVICE_INSTANCE_ID]: env.sessionId,
[SemanticResourceAttributes.DEVICE_ID]: env.machineId.slice(0, 8),
})
});
const contextManager = new AsyncHooksContextManager();
contextManager.enable();
api.context.setGlobalContextManager(contextManager);
if (env.isTelemetryEnabled) {
this.sdk.start();
} What I'm saying is that I am not skilled at opentelemetry implementations, and must rely heavily on documentation and examples. I'm not able to find the documentation and example I need to adapt my cut-and-pasted implementation. I'm certain that in a few weeks, if I should need to dive deeper into the internals of opentelemetry, the answer to my question will be obvious. But that answer is not obvious today, and diving deep into learning opentelemetry is daunting because of the apparently frequent API changes make it hard to know what's current and what is not (which means Google's and Stackoverflow's answers are frustratingly outdated). Would you kindly point me precisely to a js/ts snippet that I might be able to easily adapt without in-depth knowledge of opentelemetry? I'm not dumb, but I don't have the time or inclination for the requisite deep dive. The description of the TLDR, yes. I read the entire thread. |
Re: java vs javascript. The reason I comment here, although I'm looking for a js solution, is that Googling "how to remove default opentelemetry.sdk resources" doesn't lead anywhere else that seems more relevant. This Java implementation is the closest place that I can find where skipping non-default Records is mentioned. It seems everyone else who uses OPTL doesn't care about the unneeded attributes being using up bandwidth. Please do show a full Java example. I can try ChatGPT to translate it into the equivalent javascript incantation, although ChatGPT does not have info about the new API function (re)names. |
In Java it's just |
@drok Is there some reason you aren't asking this in the javascript repository/slack? There is very little chance that ChatGPT will be able to do any translation of APIs between the javascript SDK and the java SDK. |
Describe the bug
OTel semantic conventions mandate certain resource attributes to present, see telemetry sdk semantic conventions. I'm not sure why it is possible to remove the mandatory defaults but looking at the docs/examples, it seems it is intentional. I think it should be impossible to remove these attributes.
Steps to reproduce
This will erase the mandatory defaults:
Users need to run extra circles to add them back:
What did you expect to see?
Mandatory resource attributes should be always there even if the users call
setResource
onSdkTracerProviderBuilder
.What did you see instead?
Mandatory resource attributes are missing.
What version and what artifacts are you using?
Artifacts:
opentelemetry-sdk
Version:
1.27.0
How did you reference these artifacts?
implementation 'io.opentelemetry:opentelemetry-sdk:1.27.0'
Environment
Compiler: liberica-20.0.1+10
OS: MacOS 13.4.1
Additional context
N/A
The text was updated successfully, but these errors were encountered: