Skip to content
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

anurag4DSB
Copy link
Collaborator

@anurag4DSB anurag4DSB commented Jan 8, 2025

  1. 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.

  2. 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.

  3. Script Adjustments for E2E Testing
    • Disabled tracing in e2e feature tests to verify the system’s default behavior without tracing enabled.

Copy link

codecov bot commented Jan 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.47%. Comparing base (be74859) to head (2d4b483).
Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

Components Coverage Δ
🏠 Main Package ∅ <ø> (∅)
🚗 Driver Package 92.22% <ø> (ø)
📡 gRPC Factory Package 82.35% <ø> (ø)
🔐 IAM Client Package 98.17% <ø> (ø)
🌐 S3 Client Package 94.33% <ø> (ø)
🔧 Util Package 100.00% <ø> (ø)
🔖 Constants Package ∅ <ø> (∅)
@@           Coverage Diff           @@
##             main      #89   +/-   ##
=======================================
  Coverage   92.47%   92.47%           
=======================================
  Files          11       11           
  Lines         771      771           
=======================================
  Hits          713      713           
  Misses         49       49           
  Partials        9        9           

@anurag4DSB anurag4DSB force-pushed the improvement/COSI-61-disable-trace-export-if-endpoint-not-specified branch from 95fe631 to 06f9ffa Compare January 8, 2025 12:06
Comment on lines +37 to 53
# 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"
Copy link
Collaborator Author

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

@anurag4DSB anurag4DSB changed the title COSI-61 disable trace export if endpoint not specified and capture logs for helm validation COSI-61 disable trace export if endpoint not specified and test new default behaviour Jan 8, 2025
@anurag4DSB anurag4DSB changed the title COSI-61 disable trace export if endpoint not specified and test new default behaviour COSI-61 disable trace export if endpoint not specified(default) and test new default behaviour Jan 8, 2025
@anurag4DSB anurag4DSB changed the title COSI-61 disable trace export if endpoint not specified(default) and test new default behaviour COSI-61 disable trace export if endpoint not specified(default) and test new default behaviour in e2e feature tests (stdout export remains same) Jan 8, 2025
@anurag4DSB anurag4DSB marked this pull request as ready for review January 8, 2025 12:13
@@ -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 != "" {
Copy link

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?

Copy link
Collaborator Author

@anurag4DSB anurag4DSB Jan 8, 2025

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?

Copy link

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

Copy link
Collaborator Author

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.
Screenshot 2025-01-09 at 11 59 47

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.

Copy link
Collaborator Author

@anurag4DSB anurag4DSB Jan 9, 2025

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()

@anurag4DSB anurag4DSB requested a review from fredmnl January 8, 2025 17:42
@@ -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 != "" {
Copy link

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

@anurag4DSB anurag4DSB force-pushed the feature/COSI-61-enable-otel-traces-for-cosi-driver branch 3 times, most recently from 2f8bbe8 to be74859 Compare January 9, 2025 10:50
- Default functionality is to not export traces
- Updated e2e tests for help to verify the same
@anurag4DSB anurag4DSB force-pushed the improvement/COSI-61-disable-trace-export-if-endpoint-not-specified branch from 06f9ffa to 2d4b483 Compare January 9, 2025 10:54
Base automatically changed from feature/COSI-61-enable-otel-traces-for-cosi-driver to main January 9, 2025 10:57
@anurag4DSB anurag4DSB merged commit f028105 into main Jan 9, 2025
6 checks passed
@anurag4DSB anurag4DSB deleted the improvement/COSI-61-disable-trace-export-if-endpoint-not-specified branch January 9, 2025 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants