fix(eventing): suppress verbose OTEL logging in EventTransform#8866
fix(eventing): suppress verbose OTEL logging in EventTransform#8866khushiiagrawal wants to merge 2 commits intoknative:mainfrom
Conversation
Signed-off-by: khushiiagrawal <khushisaritaagrawal@gmail.com>
|
Welcome @khushiiagrawal! It looks like this is your first PR to knative/eventing 🎉 |
|
Hi @khushiiagrawal. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/retest |
|
@khushiiagrawal: Cannot trigger testing until a trusted user reviews the PR and leaves an DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@creydr a gentle ping 😄 |
|
/ok-to-test |
|
@creydr all the tests have been passed, do let me know if any other changes required :) |
|
@Cali0707 could you please take a look once you get some time. |
Cali0707
left a comment
There was a problem hiding this comment.
Thanks for working on this @khushiiagrawal - nice start!
I added some comments around changes I think we will need, and then this should be good to merge
| // These are standard OpenTelemetry environment variables that the Node.js SDK | ||
| // automatically reads to configure the trace exporter. | ||
| OTELExporterEndpointEnv = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT" | ||
| OTELExporterProtocolEnv = "OTEL_EXPORTER_OTLP_PROTOCOL" |
There was a problem hiding this comment.
since we are setting the endpoint for just traces, let's also only specify the protocol for traces. Otherwise this will affect logs and metrics as well (without us providing an endpoint for those).
| OTELExporterProtocolEnv = "OTEL_EXPORTER_OTLP_PROTOCOL" | |
| OTELExporterProtocolEnv = "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL" |
| } | ||
|
|
||
| // Configure sampling if a sampling rate is set | ||
| if tracingCfg.SamplingRate > 0 { |
There was a problem hiding this comment.
maybe handle the case where tracingCfg.SamplingRate == 0 - in thise case we would want the sampler to be set to always_off
There was a problem hiding this comment.
let's also check when SamplingRate == 1, as then we would want always_on, to avoid the extra computations of sampling and preserve expected semantics from the config
| append( | ||
| []corev1.EnvVar{ | ||
| { | ||
| Name: "JSONATA_TRANSFORM_FILE_NAME", | ||
| Value: filepath.Join(JsonataExpressionPath, JsonataExpressionDataKey), | ||
| }, | ||
| }, | ||
| }, | ||
| cw.ToEnvVars()..., | ||
| cw.ToEnvVars()..., | ||
| ), | ||
| otelTracingEnvVars(cw)..., |
There was a problem hiding this comment.
let's add some test cases to eventtransform_test.go that verify that the env vars are set correctly on the deployment
| { | ||
| Name: "JSONATA_TRANSFORM_FILE_NAME", | ||
| Value: filepath.Join(JsonataExpressionPath, JsonataExpressionDataKey), | ||
| append( |
There was a problem hiding this comment.
Can you try to refactor this somehow? Having two nested appends here is somewhat hard to read.
…onata deployment Signed-off-by: khushiiagrawal <khushisaritaagrawal@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: khushiiagrawal The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@Cali0707 thank you so much for the review. i have addressed all the changes, please take a look. |
|
@Cali0707 a gentle ping 😄 |
Fixes #8846
Currently, when Eventing telemetry is enabled, the
transform-jsonatacomponent defaults to using theConsoleSpanExporter. This causes verbose JSON trace data to be flooded into the container logs (stdout) instead of being sent to the configured OpenTelemetry collector. This makes the logs difficult to read and prevents traces from reaching the centralized monitoring system.Proposed Changes
This PR updates the
transform-jsonatadeployment to properly configure the OpenTelemetry SDK for Node.js:Injects Standard OTEL Config: Modified
pkg/reconciler/eventtransform/resources_jsonata.goto generate standard OpenTelemetry environment variables (OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,OTEL_EXPORTER_OTLP_PROTOCOL,OTEL_TRACES_SAMPLER, etc.) derived from the Knativeconfig-observabilitymap.Enables Auto-Configuration: By passing these environment variables, the Node.js OTEL SDK in the container can now automatically detect the correct configuration and switch from the console exporter to the OTLP exporter, respecting the user's tracing endpoint and sampling settings.
Pre-review Checklist
Release Note
Docs