feat: allow providing arbitrary extra attributes to fiber_tracing middleware resource

This commit is contained in:
Natalia Goc 2024-09-24 15:59:57 +02:00
parent 9a1b41b1ad
commit 019de457c9

View File

@ -23,17 +23,22 @@ type Config struct {
AppName string AppName string
Version string Version string
// Name of an organization providing the service // Name of an organization providing the service
ServiceProvider string ServiceProvider string
Exporters []exporters.TraceExporter Exporters []exporters.TraceExporter
ResourceAttributes []attribute.KeyValue
} }
func newResource(config Config) *resource.Resource { func newResource(config Config) *resource.Resource {
r := resource.NewWithAttributes( allAttributes := make([]attribute.KeyValue, 0, 3)
semconv.SchemaURL, allAttributes = append(
semconv.ServiceNameKey.String(config.AppName), allAttributes,
semconv.ServiceVersionKey.String(config.Version), semconv.ServiceName(config.AppName),
semconv.ServiceVersion(config.Version),
attribute.String("service.provider", config.ServiceProvider), attribute.String("service.provider", config.ServiceProvider),
) )
allAttributes = append(allAttributes, config.ResourceAttributes...)
r := resource.NewWithAttributes(semconv.SchemaURL, allAttributes...)
return r return r
} }