Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go code-excerpts don't match submodule #5629

Closed
chalin opened this issue Nov 18, 2024 · 0 comments · Fixed by #5630
Closed

Go code-excerpts don't match submodule #5629

chalin opened this issue Nov 18, 2024 · 0 comments · Fixed by #5630

Comments

@chalin
Copy link
Contributor

chalin commented Nov 18, 2024

Originally posted by @chalin in #5610 (review)


@jack-berg - if I execute npm run code-excerpts, then I get the following page updates:

diff --git a/content/en/docs/languages/go/getting-started.md ...
diff --git a/content/en/docs/languages/go/getting-started.md b/content/en/docs/languages/go/getting-started.md
index 0294d82c..b122280a 100644
--- a/content/en/docs/languages/go/getting-started.md
+++ b/content/en/docs/languages/go/getting-started.md
@@ -377,25 +377,22 @@ Modify `rolldice.go` to include custom instrumentation using OpenTelemetry API:
 package main
 
 import (
-       "fmt"
-       "io"
-       "log"
-       "math/rand"
-       "net/http"
-       "strconv"
-
        "go.opentelemetry.io/contrib/bridges/otelslog"
        "go.opentelemetry.io/otel"
-       "go.opentelemetry.io/otel/attribute"
        "go.opentelemetry.io/otel/metric"
+       "go.opentelemetry.io/otel/sdk/instrumentation"
 )
 
-const name = "go.opentelemetry.io/otel/example/dice"
+const name = "rolldice"
 
 var (
        tracer = otel.Tracer(name)
        meter  = otel.Meter(name)
-       logger = otelslog.NewLogger(name)
+       logger = otelslog.NewLogger(
+               otelslog.WithInstrumentationScope(instrumentation.Scope{
+                       Name: name,
+               }),
+       )
        rollCnt metric.Int64Counter
 )
 
@@ -408,30 +405,6 @@ func init() {
                panic(err)
        }
 }
-
-func rolldice(w http.ResponseWriter, r *http.Request) {
-       ctx, span := tracer.Start(r.Context(), "roll")
-       defer span.End()
-
-       roll := 1 + rand.Intn(6)
-
-       var msg string
-       if player := r.PathValue("player"); player != "" {
-               msg = fmt.Sprintf("%s is rolling the dice", player)
-       } else {
-               msg = "Anonymous player is rolling the dice"
-       }
-       logger.InfoContext(ctx, msg, "result", roll)
-
-       rollValueAttr := attribute.Int("roll.value", roll)
-       span.SetAttributes(rollValueAttr)
-       rollCnt.Add(ctx, 1, metric.WithAttributes(rollValueAttr))
-
-       resp := strconv.Itoa(roll) + "\n"
-       if _, err := io.WriteString(w, resp); err != nil {
-               log.Printf("Write failed: %v\n", err)
-       }
-}
 ```
 <!-- prettier-ignore-end -->

Is this expected?


Related: #5276 (comment), @svrnm wrote:

Go can currently not be updated due to https://github.com/open-telemetry/opentelemetry-go/issues/5812, I think you can safely revert that change.

@chalin, PTAL as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant