Skip to content

Commit

Permalink
Adding View option to Beholder config (#958)
Browse files Browse the repository at this point in the history
* Adding View option to Beholder config

* updating to a slice of metric views

* fixing httm meter provider

* attempting to fix ExampleConfig test
  • Loading branch information
patrickhuie19 authored Dec 6, 2024
1 parent 29871ce commit b6684ee
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/beholder/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ func newMeterProvider(config Config, resource *sdkresource.Resource, creds crede
sdkmetric.WithInterval(config.MetricReaderInterval), // Default is 10s
)),
sdkmetric.WithResource(resource),
sdkmetric.WithView(config.MetricViews...),
)
return mp, nil
}
2 changes: 2 additions & 0 deletions pkg/beholder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"time"

otelattr "go.opentelemetry.io/otel/attribute"
sdkmetric "go.opentelemetry.io/otel/sdk/metric"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

Expand All @@ -28,6 +29,7 @@ type Config struct {
// OTel Metric
MetricReaderInterval time.Duration
MetricRetryConfig *RetryConfig
MetricViews []sdkmetric.View
// OTel Log
LogExportTimeout time.Duration
// Batch processing is enabled by default
Expand Down
2 changes: 1 addition & 1 deletion pkg/beholder/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ func ExampleConfig() {
}
fmt.Printf("%+v\n", *config.LogRetryConfig)
// Output:
// {InsecureConnection:true CACertFile: OtelExporterGRPCEndpoint:localhost:4317 OtelExporterHTTPEndpoint:localhost:4318 ResourceAttributes:[{Key:package_name Value:{vtype:4 numeric:0 stringly:beholder slice:<nil>}} {Key:sender Value:{vtype:4 numeric:0 stringly:beholderclient slice:<nil>}}] EmitterExportTimeout:1s EmitterBatchProcessor:true TraceSampleRatio:1 TraceBatchTimeout:1s TraceSpanExporter:<nil> TraceRetryConfig:<nil> MetricReaderInterval:1s MetricRetryConfig:<nil> LogExportTimeout:1s LogBatchProcessor:true LogRetryConfig:<nil> AuthPublicKeyHex: AuthHeaders:map[]}
// {InsecureConnection:true CACertFile: OtelExporterGRPCEndpoint:localhost:4317 OtelExporterHTTPEndpoint:localhost:4318 ResourceAttributes:[{Key:package_name Value:{vtype:4 numeric:0 stringly:beholder slice:<nil>}} {Key:sender Value:{vtype:4 numeric:0 stringly:beholderclient slice:<nil>}}] EmitterExportTimeout:1s EmitterBatchProcessor:true TraceSampleRatio:1 TraceBatchTimeout:1s TraceSpanExporter:<nil> TraceRetryConfig:<nil> MetricReaderInterval:1s MetricRetryConfig:<nil> MetricViews:[] LogExportTimeout:1s LogBatchProcessor:true LogRetryConfig:<nil> AuthPublicKeyHex: AuthHeaders:map[]}
// {InitialInterval:5s MaxInterval:30s MaxElapsedTime:1m0s}
}
1 change: 1 addition & 0 deletions pkg/beholder/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ func newHTTPMeterProvider(config Config, resource *sdkresource.Resource, tlsConf
sdkmetric.WithInterval(config.MetricReaderInterval), // Default is 10s
)),
sdkmetric.WithResource(resource),
sdkmetric.WithView(config.MetricViews...),
)
return mp, nil
}

0 comments on commit b6684ee

Please sign in to comment.