Support for resource injection (#3383)

Co-authored-by: Kevin Wan <wanjunfeng@gmail.com>
This commit is contained in:
唐小鸭
2023-10-23 21:22:16 +08:00
committed by GitHub
parent c2ff00883a
commit e20ccdd011
2 changed files with 13 additions and 1 deletions

View File

@@ -113,11 +113,13 @@ func createExporter(c Config) (sdktrace.SpanExporter, error) {
}
func startAgent(c Config) error {
AddResources(semconv.ServiceNameKey.String(c.Name))
opts := []sdktrace.TracerProviderOption{
// Set the sampling rate based on the parent span to 100%
sdktrace.WithSampler(sdktrace.ParentBased(sdktrace.TraceIDRatioBased(c.Sampler))),
// Record information about this application in a Resource.
sdktrace.WithResource(resource.NewSchemaless(semconv.ServiceNameKey.String(c.Name))),
sdktrace.WithResource(resource.NewSchemaless(attrResources...)),
}
if len(c.Endpoint) > 0 {