Skip to content

Commit c9b6f53

Browse files
committed
yaml tags on telemetry.Config
Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>
1 parent 01f0853 commit c9b6f53

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

pkg/telemetry/config.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,50 +20,50 @@ import (
2020
// Config holds the configuration for OpenTelemetry instrumentation.
2121
type Config struct {
2222
// Endpoint is the OTLP endpoint URL
23-
Endpoint string `json:"endpoint"`
23+
Endpoint string `json:"endpoint" yaml:"endpoint"`
2424

2525
// ServiceName is the service name for telemetry
26-
ServiceName string `json:"serviceName"`
26+
ServiceName string `json:"serviceName" yaml:"serviceName"`
2727

2828
// ServiceVersion is the service version for telemetry
29-
ServiceVersion string `json:"serviceVersion"`
29+
ServiceVersion string `json:"serviceVersion" yaml:"serviceVersion"`
3030

3131
// TracingEnabled controls whether distributed tracing is enabled
3232
// When false, no tracer provider is created even if an endpoint is configured
33-
TracingEnabled bool `json:"tracingEnabled"`
33+
TracingEnabled bool `json:"tracingEnabled" yaml:"tracingEnabled"`
3434

3535
// MetricsEnabled controls whether OTLP metrics are enabled
3636
// When false, OTLP metrics are not sent even if an endpoint is configured
3737
// This is independent of EnablePrometheusMetricsPath
38-
MetricsEnabled bool `json:"metricsEnabled"`
38+
MetricsEnabled bool `json:"metricsEnabled" yaml:"metricsEnabled"`
3939

4040
// SamplingRate is the trace sampling rate (0.0-1.0)
4141
// Only used when TracingEnabled is true
42-
SamplingRate float64 `json:"samplingRate"`
42+
SamplingRate float64 `json:"samplingRate" yaml:"samplingRate"`
4343

4444
// Headers contains authentication headers for the OTLP endpoint
45-
Headers map[string]string `json:"headers"`
45+
Headers map[string]string `json:"headers" yaml:"headers"`
4646

4747
// Insecure indicates whether to use HTTP instead of HTTPS for the OTLP endpoint
48-
Insecure bool `json:"insecure"`
48+
Insecure bool `json:"insecure" yaml:"insecure"`
4949

5050
// EnablePrometheusMetricsPath controls whether to expose Prometheus-style /metrics endpoint
5151
// The metrics are served on the main transport port at /metrics
5252
// This is separate from OTLP metrics which are sent to the Endpoint
53-
EnablePrometheusMetricsPath bool `json:"enablePrometheusMetricsPath"`
53+
EnablePrometheusMetricsPath bool `json:"enablePrometheusMetricsPath" yaml:"enablePrometheusMetricsPath"`
5454

5555
// EnvironmentVariables is a list of environment variable names that should be
5656
// included in telemetry spans as attributes. Only variables in this list will
5757
// be read from the host machine and included in spans for observability.
5858
// Example: []string{"NODE_ENV", "DEPLOYMENT_ENV", "SERVICE_VERSION"}
59-
EnvironmentVariables []string `json:"environmentVariables"`
59+
EnvironmentVariables []string `json:"environmentVariables" yaml:"environmentVariables"`
6060

6161
// CustomAttributes contains custom resource attributes to be added to all telemetry signals.
6262
// These are parsed from CLI flags (--otel-custom-attributes) or environment variables
6363
// (OTEL_RESOURCE_ATTRIBUTES) as key=value pairs.
6464
// We use map[string]string for proper JSON serialization instead of []attribute.KeyValue
6565
// which doesn't marshal/unmarshal correctly.
66-
CustomAttributes map[string]string `json:"customAttributes,omitempty"`
66+
CustomAttributes map[string]string `json:"customAttributes,omitempty" yaml:"customAttributes,omitempty"`
6767
}
6868

6969
// DefaultConfig returns a default telemetry configuration.

pkg/vmcp/config/yaml_loader_transform_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -776,22 +776,21 @@ func TestYAMLLoader_transformCompositeTools_WithOutputConfig(t *testing.T) {
776776
func TestYAMLLoader_transformTelemetryConfig(t *testing.T) {
777777
t.Parallel()
778778

779-
// Note: yaml.v3 uses lowercase field names by default (no yaml tags on telemetry.Config)
780779
yamlContent := `
781780
name: telemetry-test
782781
telemetry:
783782
endpoint: "localhost:4318"
784-
servicename: "test-service"
785-
serviceversion: "1.2.3"
786-
tracingenabled: true
787-
metricsenabled: true
788-
samplingrate: 0.75
783+
serviceName: "test-service"
784+
serviceVersion: "1.2.3"
785+
tracingEnabled: true
786+
metricsEnabled: true
787+
samplingRate: 0.75
789788
insecure: true
790-
enableprometheusmetricspath: true
789+
enablePrometheusMetricsPath: true
791790
headers:
792791
Authorization: "Bearer token123"
793792
X-Custom-Header: "custom-value"
794-
environmentvariables:
793+
environmentVariables:
795794
- "NODE_ENV"
796795
- "DEPLOYMENT_ENV"
797796
`

0 commit comments

Comments
 (0)