Skip to content

Commit

Permalink
[docs] update resource initialization (#2844)
Browse files Browse the repository at this point in the history
* [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>
  • Loading branch information
3 people committed Apr 25, 2022
1 parent 1eef145 commit b8e4241
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions website_docs/manual.md
Expand Up @@ -46,15 +46,22 @@ func newExporter(ctx context.Context) /* (someExporter.Exporter, error) */ {
}

func newTraceProvider(exp sdktrace.SpanExporter) *sdktrace.TracerProvider {
// The service.name attribute is required.
resource := resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceNameKey.String("ExampleService"),
// Ensure default SDK resources and the required service name are set.
r, err := resource.Merge(
resource.Default(),
resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceNameKey.String("ExampleService"),
)
)

if err != nil {
panic(err)
}

return sdktrace.NewTracerProvider(
sdktrace.WithBatcher(exp),
sdktrace.WithResource(resource),
sdktrace.WithResource(r),
)
}

Expand Down

0 comments on commit b8e4241

Please sign in to comment.