From 019de457c9a65e283770fa8a80368fc59983eb5b Mon Sep 17 00:00:00 2001 From: Natalia Goc Date: Tue, 24 Sep 2024 15:59:57 +0200 Subject: [PATCH] feat: allow providing arbitrary extra attributes to fiber_tracing middleware resource --- pkg/fiber_tracing/fiber_tracing.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pkg/fiber_tracing/fiber_tracing.go b/pkg/fiber_tracing/fiber_tracing.go index e09bd55..9d61b12 100644 --- a/pkg/fiber_tracing/fiber_tracing.go +++ b/pkg/fiber_tracing/fiber_tracing.go @@ -23,17 +23,22 @@ type Config struct { AppName string Version string // Name of an organization providing the service - ServiceProvider string - Exporters []exporters.TraceExporter + ServiceProvider string + Exporters []exporters.TraceExporter + ResourceAttributes []attribute.KeyValue } func newResource(config Config) *resource.Resource { - r := resource.NewWithAttributes( - semconv.SchemaURL, - semconv.ServiceNameKey.String(config.AppName), - semconv.ServiceVersionKey.String(config.Version), + allAttributes := make([]attribute.KeyValue, 0, 3) + allAttributes = append( + allAttributes, + semconv.ServiceName(config.AppName), + semconv.ServiceVersion(config.Version), attribute.String("service.provider", config.ServiceProvider), ) + allAttributes = append(allAttributes, config.ResourceAttributes...) + + r := resource.NewWithAttributes(semconv.SchemaURL, allAttributes...) return r }