-
Notifications
You must be signed in to change notification settings - Fork 185
fix(tracing): disable tracing when no collector is configured #905
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,9 @@ type Config struct { | |
| Endpoint string `yaml:"endpoint" json:"endpoint"` | ||
| // Insecure determines whether to use an insecure connection (no TLS) | ||
| Insecure bool `yaml:"insecure" json:"insecure"` | ||
| // Adding extra flag to check if tracing is enabled | ||
| Enabled *bool `yaml:"enabled" json:"enabled"` | ||
|
|
||
| } | ||
|
|
||
| func InitTracerFromYamlConfig(ctx context.Context, config string) (*sdktrace.TracerProvider, error) { | ||
|
|
@@ -43,6 +46,10 @@ func InitTracerFromYamlConfig(ctx context.Context, config string) (*sdktrace.Tra | |
| // It sets up OTLP gRPC exporter, resource attributes, and W3C trace context propagation | ||
| func InitTracer(ctx context.Context, cfg Config) (*sdktrace.TracerProvider, error) { | ||
| // Validate configuration | ||
| if cfg.Enabled != nil && !*cfg.Enabled { | ||
| return nil, nil | ||
| } | ||
|
Comment on lines
+49
to
+51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check correctly handles explicit disabling via the To fix this, the logic should be changed to disable tracing by default when |
||
|
|
||
| if cfg.ServiceName == "" { | ||
| return nil, fmt.Errorf("service name is required") | ||
| } | ||
|
|
||
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.
This comment is redundant as the field name
Enabledis self-explanatory. In Go, comments are most effective when they clarify non-obvious aspects of the code. A more useful comment would describe the behavior when this field is not set (e.g., how it interacts with theEndpointconfiguration).