Skip to content

Commit f4b6093

Browse files
bramweltclaude
andcommitted
fix(review): address PR #33 review feedback
Address review comments from copilot[bot]: - pkg/utils/otel.go: guard service.name attribute on non-empty value - pkg/utils/otel.go: fix ServiceVersion doc comment re: default - pkg/utils/otel.go: loosen OTEL_*_EXPORTER doc to reference autoexport - cmd/voting-api/main.go: fix comment ("Command-line" → "Environment variable") Resolves 4 review threads. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Issue: LFXV2-1735 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
1 parent 2ce17ff commit f4b6093

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

cmd/voting-api/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func run() int {
5151
logger := slog.Default()
5252

5353
// Set up OpenTelemetry SDK.
54-
// Command-line/environment OTEL_SERVICE_VERSION takes precedence over
54+
// Environment variable OTEL_SERVICE_VERSION takes precedence over
5555
// the build-time Version variable.
5656
otelConfig := utils.OTelConfigFromEnv()
5757
if otelConfig.ServiceVersion == "" {

pkg/utils/otel.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type OTelConfig struct {
3030
// Env: OTEL_SERVICE_NAME (default: "lfx-v2-voting-service")
3131
ServiceName string
3232
// ServiceVersion is the version of the service.
33-
// Env: OTEL_SERVICE_VERSION (default: build-time version from ldflags)
33+
// Env: OTEL_SERVICE_VERSION (no default; caller may set from build-time ldflags)
3434
ServiceVersion string
3535
}
3636

@@ -65,7 +65,7 @@ func SetupOTelSDK(ctx context.Context) (shutdown func(context.Context) error, er
6565
// If it does not return an error, make sure to call shutdown for proper cleanup.
6666
//
6767
// Exporter type, protocol, and endpoint are configured via standard OTEL_* env vars:
68-
// - OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER, OTEL_LOGS_EXPORTER ("otlp" or "none")
68+
// - OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER, OTEL_LOGS_EXPORTER (as supported by autoexport, e.g. "otlp", "none", "stdout")
6969
// - OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL ("grpc" or "http/protobuf")
7070
// - OTEL_PROPAGATORS ("tracecontext,baggage,jaeger" etc.)
7171
// - OTEL_TRACES_SAMPLER ("always_on", "always_off", "traceidratio", "parentbased_*")
@@ -132,8 +132,9 @@ func SetupOTelSDKWithConfig(ctx context.Context, cfg OTelConfig) (shutdown func(
132132

133133
// newResource creates an OpenTelemetry resource with service name and version attributes.
134134
func newResource(cfg OTelConfig) (*resource.Resource, error) {
135-
attrs := []attribute.KeyValue{
136-
semconv.ServiceName(cfg.ServiceName),
135+
var attrs []attribute.KeyValue
136+
if cfg.ServiceName != "" {
137+
attrs = append(attrs, semconv.ServiceName(cfg.ServiceName))
137138
}
138139
if cfg.ServiceVersion != "" {
139140
attrs = append(attrs, semconv.ServiceVersion(cfg.ServiceVersion))

0 commit comments

Comments
 (0)