mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-10 00:29:12 +02:00
[docs] update resource initialization (#2844)
* [docs] update resource initialization * Formatting * [docs] handle error case in resource merge * Update manual.md Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com> Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
parent
1eef1459aa
commit
b8e4241a32
@ -46,15 +46,22 @@ func newExporter(ctx context.Context) /* (someExporter.Exporter, error) */ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newTraceProvider(exp sdktrace.SpanExporter) *sdktrace.TracerProvider {
|
func newTraceProvider(exp sdktrace.SpanExporter) *sdktrace.TracerProvider {
|
||||||
// The service.name attribute is required.
|
// Ensure default SDK resources and the required service name are set.
|
||||||
resource := resource.NewWithAttributes(
|
r, err := resource.Merge(
|
||||||
semconv.SchemaURL,
|
resource.Default(),
|
||||||
semconv.ServiceNameKey.String("ExampleService"),
|
resource.NewWithAttributes(
|
||||||
|
semconv.SchemaURL,
|
||||||
|
semconv.ServiceNameKey.String("ExampleService"),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
return sdktrace.NewTracerProvider(
|
return sdktrace.NewTracerProvider(
|
||||||
sdktrace.WithBatcher(exp),
|
sdktrace.WithBatcher(exp),
|
||||||
sdktrace.WithResource(resource),
|
sdktrace.WithResource(r),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user