-
Notifications
You must be signed in to change notification settings - Fork 0
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
COSI-61 disable trace export if endpoint not specified(default) and test new default behaviour in e2e feature tests (stdout export remains same) #89
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files
@@ Coverage Diff @@
## main #89 +/- ##
=======================================
Coverage 92.47% 92.47%
=======================================
Files 11 11
Lines 771 771
=======================================
Hits 713 713
Misses 49 49
Partials 9 9 |
95fe631
to
06f9ffa
Compare
# Configure tracing for the application. | ||
|
||
# If both `otel_stdout` and `otel_endpoint` are set, `otel_stdout` takes precedence. | ||
# Set `otel_stdout: false` and `otel_endpoint: ""` to disable tracing entirely. | ||
|
||
# The endpoint of the trace collector to which traces will be sent. | ||
# Use an empty string ("") to disable endpoint-based trace collection. | ||
# Use the format "http://<host>:<port>/v1/trace" to specify the collector endpoint. | ||
otel_endpoint: "" | ||
|
||
# Enable stdout tracing by setting this to true. When enabled, traces will be printed | ||
# to the console instead of being sent to the collector endpoint. | ||
otel_stdout: false | ||
# Trace span service name | ||
|
||
# The name of the service to appear in trace spans, used for identification | ||
# in observability tools. | ||
otel_service_name: "cosi.scality.com" |
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.
These are defaults.
In the CI we do have tracing enabled as we enable it using --set traces.otel_stdout=true
helm install scality-cosi-driver ./helm/scality-cosi-driver \
--namespace scality-object-storage \
--create-namespace \
--set image.tag=latest \
--set traces.otel_stdout=true
@@ -98,13 +99,17 @@ func initOpenTelemetry(ctx context.Context) (*sdktrace.TracerProvider, error) { | |||
return nil, fmt.Errorf("failed to initialize stdout exporter: %w", err) | |||
} | |||
klog.Info("OpenTelemetry tracing enabled with stdout exporter") | |||
} else { | |||
// Configure OTLP exporter | |||
} else if *driverOtelEndpoint != "" { |
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.
Is this guaranteed to be non-nil?
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.
Yes, I think *driverOtelEndpoint
is guaranteed to be non-nil because it is defined as a pointer to a string variable initialized via the flag.String function.
The flag.String function initializes driverOtelEndpoint with a valid pointer to the default value (defaultOtelEndpoint), which is an empty string (""). This means that driverOtelEndpoint will never be nil during program execution, as long as flag.Parse() is called before accessing the variable.
Are you seeing something I do not see yet?
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.
No you're absolutely right. It's just so strange that flag.String
returns a *string
even though it never returns a nil
value. I guess it's nil until the call to the flag
package is done.
LGTM
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.
So, before flag.Parse()
: Technically, the flag.String
call initializes the pointer immediately. Thus, even before flag.Parse()
, the pointer itself is not nil. However, the value it points to will not reflect any command-line overrides until flag.Parse() is invoked.
I have that strange feeling as well, for me it came from the expectation pointers to potentially be nil. But in the case of the flag package, the pointers are always initialized because flag.String (and its siblings) guarantee that.
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.
var example = flag.String("example", "default", "an example flag")
fmt.Println(*example) // Safe: Prints "default" even before flag.Parse()
@@ -98,13 +99,17 @@ func initOpenTelemetry(ctx context.Context) (*sdktrace.TracerProvider, error) { | |||
return nil, fmt.Errorf("failed to initialize stdout exporter: %w", err) | |||
} | |||
klog.Info("OpenTelemetry tracing enabled with stdout exporter") | |||
} else { | |||
// Configure OTLP exporter | |||
} else if *driverOtelEndpoint != "" { |
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.
No you're absolutely right. It's just so strange that flag.String
returns a *string
even though it never returns a nil
value. I guess it's nil until the call to the flag
package is done.
LGTM
2f8bbe8
to
be74859
Compare
- Default functionality is to not export traces - Updated e2e tests for help to verify the same
06f9ffa
to
2d4b483
Compare
OpenTelemetry Configuration Updates
• Default Endpoint: Modified the default OpenTelemetry endpoint to be an empty string ("") to avoid unintended errors if no trace collector endpoint is provided.
• Tracing Logic: Updated logic to disable tracing when both otel_stdout and otel_endpoint are unset.
• Service Name: Added driverOtelServiceName to the initialization process log for better trace span identification.
Helm Chart Enhancements
• Improved Comments: Enhanced the values.yaml file with detailed comments explaining the usage of otel_stdout and otel_endpoint.
• Default Values: Updated the default values to ensure trace collection is explicitly configured by the user, avoiding unintentional trace exports.
Script Adjustments for E2E Testing
• Disabled tracing in e2e feature tests to verify the system’s default behavior without tracing enabled.