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

chore: Simplify OtelConfig #40

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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