Skip to content

Commit 031d52c

Browse files
authored
Fix complication bug in Go Resources page (#3949)
1 parent 6c787c9 commit 031d52c

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

content/en/docs/languages/go/resources.md

+14-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Resources should be assigned to a tracer provider at its initialization, and are
1010
created much like attributes:
1111

1212
```go
13-
resources := resource.NewWithAttributes(
13+
res := resource.NewWithAttributes(
1414
semconv.SchemaURL,
1515
semconv.ServiceNameKey.String("myService"),
1616
semconv.ServiceVersionKey.String("1.0.0"),
@@ -19,7 +19,7 @@ resources := resource.NewWithAttributes(
1919

2020
provider := sdktrace.NewTracerProvider(
2121
...
22-
sdktrace.WithResource(resources),
22+
sdktrace.WithResource(res),
2323
)
2424
```
2525

@@ -36,13 +36,17 @@ hosting that operating system instance, or any number of other resource
3636
attributes.
3737

3838
```go
39-
resources := resource.New(context.Background(),
40-
resource.WithFromEnv(), // pull attributes from OTEL_RESOURCE_ATTRIBUTES and OTEL_SERVICE_NAME environment variables
41-
resource.WithProcess(), // This option configures a set of Detectors that discover process information
42-
resource.WithOS(), // This option configures a set of Detectors that discover OS information
43-
resource.WithContainer(), // This option configures a set of Detectors that discover container information
44-
resource.WithHost(), // This option configures a set of Detectors that discover host information
45-
resource.WithDetectors(thirdparty.Detector{}), // Bring your own external Detector implementation
46-
resource.WithAttributes(attribute.String("foo", "bar")), // Or specify resource attributes directly
39+
res, err := resource.New(context.Background(),
40+
resource.WithFromEnv(), // Pull attributes from OTEL_RESOURCE_ATTRIBUTES and OTEL_SERVICE_NAME environment variables.
41+
resource.WithTelemetrySDK(), // Provide information about the OpenTelemetry SDK used.
42+
resource.WithProcess(), // Discover and provide process information.
43+
resource.WithOS(), // Discover and provide OS information.
44+
resource.WithContainer(), // Discover and provide container information.
45+
resource.WithHost(), // Discover and provide information.
46+
resource.WithAttributes(attribute.String("foo", "bar")), // Add custom resource attributes.
47+
// resource.WithDetectors(thirdparty.Detector{}), // Bring your own external Detector implementation.
4748
)
49+
if err != nil {
50+
log.Println(err) // Log issues during resource creation. Note that resource.New still returns a resource.
51+
}
4852
```

0 commit comments

Comments
 (0)