Skip to content

Commit

Permalink
feat(telemetry): add capacity of add new resource attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Nov 18, 2022
1 parent d871466 commit 5504055
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sharedotlp/pkg/sharedotlptraces/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type ModuleConfig struct {
Batch bool
JaegerConfig *JaegerConfig
OTLPConfig *OTLPConfig
Resource *resource.Resource
}

func ProvideTracerProviderOption(v any, annotations ...fx.Annotation) fx.Option {
Expand All @@ -51,6 +52,13 @@ func ProvideTracerProviderOption(v any, annotations ...fx.Annotation) fx.Option
func TracesModule(cfg ModuleConfig) fx.Option {
options := make([]fx.Option, 0)
options = append(options,
fx.Provide(func() (*resource.Resource, error) {
defaultResource := resource.Default()
if cfg.Resource == nil {
return defaultResource, nil
}
return resource.Merge(defaultResource, cfg.Resource)
}),
fx.Supply(resource.Default()),
fx.Provide(func(tp *tracesdk.TracerProvider) trace.TracerProvider { return tp }),
fx.Provide(fx.Annotate(func(options ...tracesdk.TracerProviderOption) *tracesdk.TracerProvider {
Expand Down

0 comments on commit 5504055

Please sign in to comment.