Skip to content

Commit

Permalink
chore: Simplify OtelConfig (#40)
Browse files Browse the repository at this point in the history
Signed-off-by: Joonas Bergius <joonas@cosmonic.com>
  • Loading branch information
joonas authored Sep 27, 2024
1 parent 1d03a52 commit f8ed71d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions host.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ func (rs RedactedString) Reveal() string {

type OtelConfig struct {
EnableObservability bool `json:"enable_observability"`
EnableTraces *bool `json:"enable_traces,omitempty"`
EnableMetrics *bool `json:"enable_metrics,omitempty"`
EnableLogs *bool `json:"enable_logs,omitempty"`
EnableTraces bool `json:"enable_traces,omitempty"`
EnableMetrics bool `json:"enable_metrics,omitempty"`
EnableLogs bool `json:"enable_logs,omitempty"`
ObservabilityEndpoint string `json:"observability_endpoint,omitempty"`
TracesEndpoint string `json:"traces_endpoint,omitempty"`
MetricsEndpoint string `json:"metrics_endpoint,omitempty"`
LogsEndpoint string `json:"logs_endpoint,omitempty"`
TraceLevel *Level `json:"trace_level,omitempty"`
Protocol string `json:"protocol,omitempty"`
}

Expand Down
6 changes: 3 additions & 3 deletions provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func NewWithHostDataSource(source io.Reader, options ...ProviderHandler) (*Wasmc
return nil, err
}

if hostData.OtelConfig.EnableObservability || (hostData.OtelConfig.EnableMetrics != nil && *hostData.OtelConfig.EnableMetrics) {
if hostData.OtelConfig.EnableObservability || hostData.OtelConfig.EnableMetrics {
meterProvider, err := newMeterProvider(context.Background(), hostData.OtelConfig, serviceResource)
if err != nil {
return nil, err
Expand All @@ -134,7 +134,7 @@ func NewWithHostDataSource(source io.Reader, options ...ProviderHandler) (*Wasmc
internalShutdownFuncs = append(internalShutdownFuncs, func(c context.Context) error { return meterProvider.Shutdown(c) })
}

if hostData.OtelConfig.EnableObservability || (hostData.OtelConfig.EnableTraces != nil && *hostData.OtelConfig.EnableTraces) {
if hostData.OtelConfig.EnableObservability || hostData.OtelConfig.EnableTraces {
tracerProvider, err := newTracerProvider(context.Background(), hostData.OtelConfig, serviceResource)
if err != nil {
return nil, err
Expand All @@ -143,7 +143,7 @@ func NewWithHostDataSource(source io.Reader, options ...ProviderHandler) (*Wasmc
internalShutdownFuncs = append(internalShutdownFuncs, func(c context.Context) error { return tracerProvider.Shutdown(c) })
}

if hostData.OtelConfig.EnableObservability || (hostData.OtelConfig.EnableLogs != nil && *hostData.OtelConfig.EnableLogs) {
if hostData.OtelConfig.EnableObservability || hostData.OtelConfig.EnableLogs {
loggerProvider, err := newLoggerProvider(context.Background(), hostData.OtelConfig, serviceResource)
if err != nil {
return nil, err
Expand Down

0 comments on commit f8ed71d

Please sign in to comment.