Skip to content

Commit

Permalink
Tidy up some fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffail committed Feb 14, 2024
1 parent f9f3c7e commit d80074c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
- Field `read_header` added to the `amqp_1` input.
- A debug endpoint `/debug/pprof/allocs` has been added for profiling allocations.
- New `cockroachdb_changefeed` input.
- The `open_telemetry_collector` tracer now supports sampling.

### Fixed

Expand Down
19 changes: 10 additions & 9 deletions internal/impl/otlp/tracer_otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,18 @@ func init() {
).Description("A list of grpc collectors.")).
Field(service.NewStringMapField("tags").
Description("A map of tags to add to all tracing spans.").
Default(map[string]string{}).
Default(map[string]any{}).
Advanced()).
Field(service.NewObjectField("sampling",
service.NewBoolField("enabled").
Description("Whether to enable sampling.").
Default(false).
Optional(),
Default(false),
service.NewFloatField("ratio").
Description("Sets the ratio of traces to sample.").
Default(1.0).
Advanced().
Examples(0.85, 0.5).
Optional()).
Description("Settings for trace sampling. Sampling is recommended for high-volume production workloads."))
Description("Settings for trace sampling. Sampling is recommended for high-volume production workloads.").
Version("4.25.0"))

err := service.RegisterOtelTracerProvider(
"open_telemetry_collector",
Expand Down Expand Up @@ -146,9 +145,11 @@ func sampleConfigFromParsed(conf *service.ParsedConfig) (sampleConfig, error) {
return sampleConfig{}, err
}

ratio, err := conf.FieldFloat("ratio")
if err != nil {
return sampleConfig{}, err
var ratio float64
if conf.Contains("ratio") {
if ratio, err = conf.FieldFloat("ratio"); err != nil {
return sampleConfig{}, err
}
}

return sampleConfig{
Expand Down
13 changes: 11 additions & 2 deletions website/docs/components/tracers/open_telemetry_collector.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ tracer:
grpc: [] # No default (required)
sampling:
enabled: false
ratio: 0.85 # No default (optional)
```
</TabItem>
Expand All @@ -48,7 +49,7 @@ tracer:
tags: {}
sampling:
enabled: false
ratio: 1
ratio: 0.85 # No default (optional)
```
</TabItem>
Expand Down Expand Up @@ -116,6 +117,7 @@ Settings for trace sampling. Sampling is recommended for high-volume production


Type: `object`
Requires version 4.25.0 or newer

### `sampling.enabled`

Expand All @@ -131,6 +133,13 @@ Sets the ratio of traces to sample.


Type: `float`
Default: `1`

```yml
# Examples
ratio: 0.85
ratio: 0.5
```


0 comments on commit d80074c

Please sign in to comment.