Incorrect type passed to OTel API leads to the exported telemetry being dropped by the backend #31459
-
What would you like help with?I think I found a bug How are you running Renovate?None If you're self-hosting Renovate, tell us which platform (GitHub, GitLab, etc) and which version of Renovate.No response Please tell us more about your question or problemDescriptionIn this spot right here (L149, L165), a caught renovate/lib/instrumentation/index.ts Lines 141 to 165 in 5ca09ed This causes the exported message to be dropped by the OTel collector with an Minimal Reproduction Steps
receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318
processors:
batch:
exporters:
debug:
service:
pipelines:
traces:
receivers: [otlp]
exporters: [debug]
processors: [batch]
Additional infoI'm a maintainer of OTel JS and we're aware that this may be a common issue to run into when using the OTel SDK. As such we're planning to add additional input validation to ensure that the OTLP export request is not dropped when such input is passed (open-telemetry/opentelemetry-js#4998). My recommendation therefore would be to update diff --git a/lib/instrumentation/index.ts b/lib/instrumentation/index.ts
index 4f33813c9..ec97f1964 100644
--- a/lib/instrumentation/index.ts
+++ b/lib/instrumentation/index.ts
@@ -143,10 +143,10 @@ export function instrument<F extends () => ReturnType<F>>(
const ret = fn();
if (ret instanceof Promise) {
return ret
- .catch((e) => {
+ .catch((e: unknown) => {
span.setStatus({
code: SpanStatusCode.ERROR,
- message: e,
+ message: e instanceof Error? e.message: undefined,
});
throw e;
})
@@ -154,10 +154,10 @@ export function instrument<F extends () => ReturnType<F>>(
}
span.end();
return ret;
- } catch (e) {
+ } catch (e: unknown) {
span.setStatus({
code: SpanStatusCode.ERROR,
- message: e,
+ message: e instanceof Error? e.message: undefined,
});
span.end();
throw e; This will fix the dropped OTLP message issue immediately, and once we, over at the OTel JS repo, have added the validation (open-telemetry/opentelemetry-js#4998), will ensure that the message will be on the exported telemetry 🙂 Logs (if relevant)
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Thanks for for the report. Will the fix also work for the experimental api export? This code has been added before that has been merged in the api package and planning on moving this over. |
Beta Was this translation helpful? Give feedback.
Will be fixed with: #31481