mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
Allow OTEL service name to be overridden (#41890)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #41888 # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. ## Testing - [x] QA'd all new/changed functionality manually <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * OpenTelemetry service name can now be configured via the standard OTEL_SERVICE_NAME environment variable * Support for OTEL_RESOURCE_ATTRIBUTES environment variable to customize telemetry resource attributes * **Chores** * Enhanced OpenTelemetry resource initialization to support environment variable overrides for improved deployment flexibility <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
8c2ad7f901
commit
d177078b40
2 changed files with 9 additions and 5 deletions
1
changes/41888-otel-service-name
Normal file
1
changes/41888-otel-service-name
Normal file
|
|
@ -0,0 +1 @@
|
|||
* Allow OTEL service name to be overridden with standard OTEL_SERVICE_NAME env var.
|
||||
|
|
@ -172,14 +172,17 @@ the way that the Fleet server works.
|
|||
var tracerProvider *sdktrace.TracerProvider
|
||||
var meterProvider *sdkmetric.MeterProvider
|
||||
if config.OTELEnabled() {
|
||||
// Create shared resource with service identification attributes
|
||||
res, err := resource.Merge(
|
||||
resource.Default(),
|
||||
resource.NewWithAttributes(
|
||||
semconv.SchemaURL,
|
||||
// Create shared resource with service identification attributes.
|
||||
// OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES env vars can override
|
||||
// the defaults below.
|
||||
res, err := resource.New(context.Background(),
|
||||
resource.WithSchemaURL(semconv.SchemaURL),
|
||||
resource.WithAttributes(
|
||||
semconv.ServiceName("fleet"),
|
||||
semconv.ServiceVersion(version.Version().Version),
|
||||
),
|
||||
resource.WithFromEnv(),
|
||||
resource.WithTelemetrySDK(),
|
||||
)
|
||||
if err != nil {
|
||||
initFatal(err, "Failed to create OTEL resource")
|
||||
|
|
|
|||
Loading…
Reference in a new issue