Skip to content

Commit 769aae6

Browse files
committed
PR feedback
1 parent 18511ff commit 769aae6

File tree

11 files changed

+1781
-1751
lines changed

11 files changed

+1781
-1751
lines changed

content/en/docs/collector/deployment/agent.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Cons:
129129
[instrumentation]: /docs/languages/
130130
[otlp]: /docs/specs/otel/protocol/
131131
[collector]: /docs/collector/
132-
[instrument-java-metrics]: /docs/languages/java/instrumentation/#metrics
132+
[instrument-java-metrics]: /docs/languages/java/api-components/#meterprovider
133133
[otlp-exporter]: /docs/specs/otel/protocol/exporter/
134134
[java-otlp-example]:
135135
https://github.com/open-telemetry/opentelemetry-java-docs/tree/main/otlp

content/en/docs/concepts/instrumentation/libraries.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ After you create a span, pass new trace context to the application code
265265
(callback or handler), by making the span active; if possible, do this
266266
explicitly. The following Java example shows how to add trace context and
267267
activate a span. See the
268-
[Context extraction in Java](/docs/languages/java/instrumentation/#context-propagation),
268+
[Context extraction in Java](/docs/languages/java/api-components/#contextpropagators),
269269
for more examples.
270270

271271
```java
@@ -289,9 +289,7 @@ try (Scope unused = span.makeCurrent()) {
289289
```
290290

291291
In the case of a messaging system, you might receive more than one message at
292-
once. Received messages become
293-
[links](/docs/languages/java/instrumentation/#create-spans-with-links) on the
294-
span you create. Refer to
292+
once. Received messages become links on the span you create. Refer to
295293
[messaging conventions](/docs/specs/semconv/messaging/messaging-spans/) for
296294
details.
297295

content/en/docs/languages/go/getting-started.md

+34-7
Original file line numberDiff line numberDiff line change
@@ -377,22 +377,25 @@ Modify `rolldice.go` to include custom instrumentation using OpenTelemetry API:
377377
package main
378378

379379
import (
380+
"fmt"
381+
"io"
382+
"log"
383+
"math/rand"
384+
"net/http"
385+
"strconv"
386+
380387
"go.opentelemetry.io/contrib/bridges/otelslog"
381388
"go.opentelemetry.io/otel"
389+
"go.opentelemetry.io/otel/attribute"
382390
"go.opentelemetry.io/otel/metric"
383-
"go.opentelemetry.io/otel/sdk/instrumentation"
384391
)
385392

386-
const name = "rolldice"
393+
const name = "go.opentelemetry.io/otel/example/dice"
387394

388395
var (
389396
tracer = otel.Tracer(name)
390397
meter = otel.Meter(name)
391-
logger = otelslog.NewLogger(
392-
otelslog.WithInstrumentationScope(instrumentation.Scope{
393-
Name: name,
394-
}),
395-
)
398+
logger = otelslog.NewLogger(name)
396399
rollCnt metric.Int64Counter
397400
)
398401

@@ -405,6 +408,30 @@ func init() {
405408
panic(err)
406409
}
407410
}
411+
412+
func rolldice(w http.ResponseWriter, r *http.Request) {
413+
ctx, span := tracer.Start(r.Context(), "roll")
414+
defer span.End()
415+
416+
roll := 1 + rand.Intn(6)
417+
418+
var msg string
419+
if player := r.PathValue("player"); player != "" {
420+
msg = fmt.Sprintf("%s is rolling the dice", player)
421+
} else {
422+
msg = "Anonymous player is rolling the dice"
423+
}
424+
logger.InfoContext(ctx, msg, "result", roll)
425+
426+
rollValueAttr := attribute.Int("roll.value", roll)
427+
span.SetAttributes(rollValueAttr)
428+
rollCnt.Add(ctx, 1, metric.WithAttributes(rollValueAttr))
429+
430+
resp := strconv.Itoa(roll) + "\n"
431+
if _, err := io.WriteString(w, resp); err != nil {
432+
log.Printf("Write failed: %v\n", err)
433+
}
434+
}
408435
```
409436
<!-- prettier-ignore-end -->
410437

0 commit comments

Comments
 (0)