-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(go): refactor tracing docs #16172
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
Open
giortzisg
wants to merge
2
commits into
master
Choose a base branch
from
docs/go/tracing-ref
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
docs/platforms/go/guides/echo/tracing/instrumentation/echo.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| title: Automatic Instrumentation | ||
| sidebar_order: 1 | ||
| sdk: sentry.go.echo | ||
| description: "Learn about tracing instrumentation for the Echo HTTP framework." | ||
| --- | ||
|
|
||
| <Alert> | ||
|
|
||
| To capture transactions, you'll need to first <PlatformLink to="/tracing/">set up tracing</PlatformLink>. | ||
|
|
||
| </Alert> | ||
|
|
||
| The `sentryecho` middleware provides automatic tracing and error capturing for Echo applications. The source can be found [on GitHub](https://github.com/getsentry/sentry-go/tree/master/echo). | ||
|
|
||
| For installation and configuration instructions, see the [Echo Getting Started](/platforms/go/guides/echo/) guide. | ||
|
|
||
| ## Automatic Instrumentation | ||
|
|
||
| <PlatformContent includePath="tracing/automatic-instrumentation/http-frameworks" /> | ||
|
|
||
| ## Adding Custom Spans | ||
|
|
||
| You can add custom child spans to track specific operations within your handlers. See the <PlatformLink to="/tracing/instrumentation/custom-instrumentation/">Custom Instrumentation</PlatformLink> documentation for details on manual span creation. | ||
|
|
||
| ## Distributed Tracing | ||
|
|
||
| The `sentryecho` middleware automatically continues traces from upstream services by reading Sentry trace headers from incoming requests. No additional configuration is needed. | ||
28 changes: 28 additions & 0 deletions
28
docs/platforms/go/guides/fasthttp/tracing/instrumentation/fasthttp.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| title: Automatic Instrumentation | ||
| sidebar_order: 1 | ||
| sdk: sentry.go.fasthttp | ||
| description: "Learn about tracing instrumentation for the FastHTTP framework." | ||
| --- | ||
|
|
||
| <Alert> | ||
|
|
||
| To capture transactions, you'll need to first <PlatformLink to="/tracing/">set up tracing</PlatformLink>. | ||
|
|
||
| </Alert> | ||
|
|
||
| The `sentryfasthttp` middleware provides automatic tracing and error capturing for FastHTTP applications. The source can be found [on GitHub](https://github.com/getsentry/sentry-go/tree/master/fasthttp). | ||
|
|
||
| For installation and configuration instructions, see the [FastHTTP Getting Started](/platforms/go/guides/fasthttp/) guide. | ||
|
|
||
| ## Automatic Instrumentation | ||
|
|
||
| <PlatformContent includePath="tracing/automatic-instrumentation/http-frameworks" /> | ||
|
|
||
| ## Adding Custom Spans | ||
|
|
||
| You can add custom child spans to track specific operations. See the <PlatformLink to="/tracing/instrumentation/custom-instrumentation/">Custom Instrumentation</PlatformLink> documentation for details on manual span creation. | ||
|
|
||
| ## Distributed Tracing | ||
|
|
||
| The `sentryfasthttp` middleware automatically continues traces from upstream services by reading Sentry trace headers from incoming requests. No additional configuration is needed. |
28 changes: 28 additions & 0 deletions
28
docs/platforms/go/guides/fiber/tracing/instrumentation/fiber.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| title: Automatic Instrumentation | ||
| sidebar_order: 1 | ||
| sdk: sentry.go.fiber | ||
| description: "Learn about tracing instrumentation for the Fiber HTTP framework." | ||
| --- | ||
|
|
||
| <Alert> | ||
|
|
||
| To capture transactions, you'll need to first <PlatformLink to="/tracing/">set up tracing</PlatformLink>. | ||
|
|
||
| </Alert> | ||
|
|
||
| The `sentryfiber` middleware provides automatic tracing and error capturing for Fiber applications. The source can be found [on GitHub](https://github.com/getsentry/sentry-go/tree/master/fiber). | ||
|
|
||
| For installation and configuration instructions, see the [Fiber Getting Started](/platforms/go/guides/fiber/) guide. | ||
|
|
||
| ## Automatic Instrumentation | ||
|
|
||
| <PlatformContent includePath="tracing/automatic-instrumentation/http-frameworks" /> | ||
|
|
||
| ## Adding Custom Spans | ||
|
|
||
| You can add custom child spans to track specific operations. See the <PlatformLink to="/tracing/instrumentation/custom-instrumentation/">Custom Instrumentation</PlatformLink> documentation for details on manual span creation. | ||
|
|
||
| ## Distributed Tracing | ||
|
|
||
| The `sentryfiber` middleware automatically continues traces from upstream services by reading Sentry trace headers from incoming requests. No additional configuration is needed. |
28 changes: 28 additions & 0 deletions
28
docs/platforms/go/guides/gin/tracing/instrumentation/gin.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| title: Automatic Instrumentation | ||
| sidebar_order: 1 | ||
| sdk: sentry.go.gin | ||
| description: "Learn about tracing instrumentation for the Gin HTTP framework." | ||
| --- | ||
|
|
||
| <Alert> | ||
|
|
||
| To capture transactions, you'll need to first <PlatformLink to="/tracing/">set up tracing</PlatformLink>. | ||
|
|
||
| </Alert> | ||
|
|
||
| The `sentrygin` middleware provides automatic tracing and error capturing for Gin applications. The source can be found [on GitHub](https://github.com/getsentry/sentry-go/tree/master/gin). | ||
|
|
||
| For installation and configuration instructions, see the [Gin Getting Started](/platforms/go/guides/gin/) guide. | ||
|
|
||
| ## Automatic Instrumentation | ||
|
|
||
| <PlatformContent includePath="tracing/automatic-instrumentation/http-frameworks" /> | ||
|
|
||
| ## Adding Custom Spans | ||
|
|
||
| You can add custom child spans to track specific operations within your handlers. See the <PlatformLink to="/tracing/instrumentation/custom-instrumentation/">Custom Instrumentation</PlatformLink> documentation for details on manual span creation. | ||
|
|
||
| ## Distributed Tracing | ||
|
|
||
| The `sentrygin` middleware automatically continues traces from upstream services by reading Sentry trace headers from incoming requests. No additional configuration is needed. |
30 changes: 30 additions & 0 deletions
30
docs/platforms/go/guides/http/tracing/instrumentation/http.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| --- | ||
| title: Automatic Instrumentation | ||
| sidebar_order: 1 | ||
| sdk: sentry.go.http | ||
| description: "Learn about tracing instrumentation for the standard library net/http package." | ||
| --- | ||
|
|
||
| <Alert> | ||
|
|
||
| To capture transactions, you'll need to first <PlatformLink to="/tracing/">set up tracing</PlatformLink>. | ||
|
|
||
| </Alert> | ||
|
|
||
| The `sentryhttp` middleware provides automatic tracing and error capturing for applications using Go's standard `net/http` package. The source can be found [on GitHub](https://github.com/getsentry/sentry-go/tree/master/http). | ||
|
|
||
| For installation and configuration instructions, see the [net/http Getting Started](/platforms/go/guides/http/) guide. | ||
|
|
||
| ## Automatic Instrumentation | ||
|
|
||
| <PlatformContent includePath="tracing/automatic-instrumentation/http-frameworks" /> | ||
|
|
||
| ## Adding Custom Spans | ||
|
|
||
| You can add custom child spans to track specific operations within your handlers. See the <PlatformLink to="/tracing/instrumentation/custom-instrumentation/">Custom Instrumentation</PlatformLink> documentation for details on manual span creation. | ||
|
|
||
| ## Distributed Tracing | ||
|
|
||
| The `sentryhttp` middleware automatically continues traces from upstream services by reading Sentry trace headers from incoming requests. No additional configuration is needed. | ||
|
|
||
| For outbound HTTP requests with tracing, see the <PlatformLink to="/tracing/instrumentation/custom-instrumentation/requests-module/">HTTP Requests</PlatformLink> documentation. |
28 changes: 28 additions & 0 deletions
28
docs/platforms/go/guides/iris/tracing/instrumentation/iris.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| title: Automatic Instrumentation | ||
| sidebar_order: 1 | ||
| sdk: sentry.go.iris | ||
| description: "Learn about tracing instrumentation for the Iris HTTP framework." | ||
| --- | ||
|
|
||
| <Alert> | ||
|
|
||
| To capture transactions, you'll need to first <PlatformLink to="/tracing/">set up tracing</PlatformLink>. | ||
|
|
||
| </Alert> | ||
|
|
||
| The `sentryiris` middleware provides automatic tracing and error capturing for Iris applications. The source can be found [on GitHub](https://github.com/getsentry/sentry-go/tree/master/iris). | ||
|
|
||
| For installation and configuration instructions, see the [Iris Getting Started](/platforms/go/guides/iris/) guide. | ||
|
|
||
| ## Automatic Instrumentation | ||
|
|
||
| <PlatformContent includePath="tracing/automatic-instrumentation/http-frameworks" /> | ||
|
|
||
| ## Adding Custom Spans | ||
|
|
||
| You can add custom child spans to track specific operations. See the <PlatformLink to="/tracing/instrumentation/custom-instrumentation/">Custom Instrumentation</PlatformLink> documentation for details on manual span creation. | ||
|
|
||
| ## Distributed Tracing | ||
|
|
||
| The `sentryiris` middleware automatically continues traces from upstream services by reading Sentry trace headers from incoming requests. No additional configuration is needed. |
92 changes: 92 additions & 0 deletions
92
docs/platforms/go/guides/logrus/tracing/instrumentation/logrus.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| --- | ||
| title: Logrus Integration with Tracing | ||
| sidebar_order: 200 | ||
| sdk: sentry.go.logrus | ||
| description: "Learn how to link Logrus logs with distributed traces." | ||
| --- | ||
|
|
||
| <Alert> | ||
|
|
||
| To link logs with traces, you'll need to first <PlatformLink to="/tracing/">set up tracing</PlatformLink>. | ||
|
|
||
| </Alert> | ||
|
|
||
| The `sentrylogrus` integration provides structured logging support. When combined with tracing, you can link your logs to traces by using `NewLogHook` with context-aware logging methods. | ||
|
|
||
| ## Linking Logs to Traces | ||
|
|
||
| To link your Logrus logs to active traces, use `NewLogHook` (which supports context) and log with `WithContext(ctx)`. | ||
|
|
||
| ### Example | ||
|
|
||
| ```go | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "net/http" | ||
| "time" | ||
|
|
||
| "github.com/getsentry/sentry-go" | ||
| sentryhttp "github.com/getsentry/sentry-go/http" | ||
| sentrylogrus "github.com/getsentry/sentry-go/logrus" | ||
| "github.com/sirupsen/logrus" | ||
| ) | ||
|
|
||
| var logger = logrus.New() | ||
|
|
||
| func main() { | ||
| // Initialize Sentry with tracing and logs enabled | ||
| if err := sentry.Init(sentry.ClientOptions{ | ||
| Dsn: "___PUBLIC_DSN___", | ||
| EnableTracing: true, | ||
| TracesSampleRate: 1.0, | ||
| EnableLogs: true, | ||
| LogsSampleRate: 1.0, | ||
| }); err != nil { | ||
| panic(err) | ||
| } | ||
| defer sentry.Flush(2 * time.Second) | ||
|
|
||
| // Use NewLogHook to send logs with context support | ||
| hook, err := sentrylogrus.NewLogHook( | ||
| []logrus.Level{logrus.InfoLevel, logrus.ErrorLevel}, | ||
| sentry.ClientOptions{ | ||
| Dsn: "___PUBLIC_DSN___", | ||
| EnableLogs: true, | ||
| }, | ||
| ) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| defer hook.Flush(5 * time.Second) | ||
| logger.AddHook(hook) | ||
|
|
||
| sentryHandler := sentryhttp.New(sentryhttp.Options{}) | ||
| http.Handle("/", sentryHandler.Handle(http.HandlerFunc(handler))) | ||
|
|
||
| fmt.Println("Listening on :3000") | ||
| http.ListenAndServe(":3000", nil) | ||
| } | ||
|
|
||
| func handler(w http.ResponseWriter, r *http.Request) { | ||
| ctx := r.Context() | ||
| // Logs with context are automatically linked to the active trace | ||
| logger.WithContext(ctx).Info("Processing request") | ||
|
|
||
| w.Write([]byte("OK")) | ||
| } | ||
| ``` | ||
|
|
||
| ## Best Practices | ||
|
|
||
| - **Use `NewLogHook` not `NewEventHook`**: Only `NewLogHook` supports context-based trace linking | ||
| - **Enable logs**: Set `EnableLogs: true` in ClientOptions | ||
| - **Use `WithContext`**: Always use `logger.WithContext(ctx)` to associate logs with the active trace | ||
| - **Log within transactions**: Ensure logs are created while a transaction or span is active | ||
|
|
||
| ## Related Documentation | ||
|
|
||
| - <PlatformLink to="/logs/">Logs</PlatformLink> - Comprehensive logging setup | ||
| - <PlatformLink to="/tracing/instrumentation/custom-instrumentation/">Custom Instrumentation</PlatformLink> - Manual tracing setup | ||
| - [Logrus Integration Guide](/platforms/go/guides/logrus/) - Full Logrus integration details |
24 changes: 24 additions & 0 deletions
24
docs/platforms/go/guides/negroni/tracing/instrumentation/negroni.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --- | ||
| title: Automatic Instrumentation | ||
| sidebar_order: 1 | ||
| sdk: sentry.go.negroni | ||
| description: "Learn about tracing instrumentation for the Negroni HTTP middleware." | ||
| --- | ||
|
|
||
| <Alert> | ||
|
|
||
| To capture transactions, you'll need to first <PlatformLink to="/tracing/">set up tracing</PlatformLink>. | ||
|
|
||
| </Alert> | ||
|
|
||
| The `sentrynegroni` middleware provides automatic tracing and error capturing for applications using Negroni. The source can be found [on GitHub](https://github.com/getsentry/sentry-go/tree/master/negroni). | ||
|
|
||
| For installation and configuration instructions, see the [Negroni Getting Started](/platforms/go/guides/negroni/) guide. | ||
|
|
||
| ## Automatic Instrumentation | ||
|
|
||
| <PlatformContent includePath="tracing/automatic-instrumentation/http-frameworks" /> | ||
|
|
||
| ## Adding Custom Spans | ||
|
|
||
| You can add custom child spans to track specific operations. See the <PlatformLink to="/tracing/instrumentation/custom-instrumentation/">Custom Instrumentation</PlatformLink> documentation for details on manual span creation. |
72 changes: 72 additions & 0 deletions
72
docs/platforms/go/guides/slog/tracing/instrumentation/slog.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| --- | ||
| title: Slog Integration with Tracing | ||
| sidebar_order: 201 | ||
| sdk: sentry.go.slog | ||
| description: "Learn how to link Slog logs with distributed traces." | ||
| --- | ||
|
|
||
| <Alert> | ||
|
|
||
| To link logs with traces, you'll need to first <PlatformLink to="/tracing/">set up tracing</PlatformLink>. | ||
|
|
||
| </Alert> | ||
|
|
||
| The `sentryslog` integration provides structured logging support for Go's standard `log/slog` package (Go 1.21+). When combined with tracing, you can link your logs to traces for better observability. | ||
|
|
||
| ## Linking Logs to Traces | ||
|
|
||
| To link your Slog logs to active traces, you need to use context-aware logging methods like `logger.InfoContext()`. | ||
|
|
||
| ### Example | ||
|
|
||
| ```go | ||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "log/slog" | ||
| "net/http" | ||
| "time" | ||
|
|
||
| "github.com/getsentry/sentry-go" | ||
| sentryhttp "github.com/getsentry/sentry-go/http" | ||
| ) | ||
|
|
||
| func main() { | ||
| // Initialize Sentry with tracing enabled | ||
| if err := sentry.Init(sentry.ClientOptions{ | ||
| Dsn: "___PUBLIC_DSN___", | ||
| EnableTracing: true, | ||
| TracesSampleRate: 1.0, | ||
| }); err != nil { | ||
| panic(err) | ||
| } | ||
| defer sentry.Flush(2 * time.Second) | ||
|
|
||
| sentryHandler := sentryhttp.New(sentryhttp.Options{}) | ||
| http.Handle("/", sentryHandler.Handle(http.HandlerFunc(handler))) | ||
|
|
||
| fmt.Println("Listening on :3000") | ||
| http.ListenAndServe(":3000", nil) | ||
| } | ||
|
|
||
| func handler(w http.ResponseWriter, r *http.Request) { | ||
| ctx := r.Context() | ||
| // Logs with context are automatically linked to the active trace | ||
| slog.InfoContext(ctx, "Processing request") | ||
|
Comment on lines
+36
to
+57
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: do we need to show how to initialize slog for sentry here too? Or put a really bold link on how to do so? |
||
|
|
||
| w.Write([]byte("OK")) | ||
| } | ||
| ``` | ||
|
|
||
| ## Best Practices | ||
|
|
||
| - **Use context-aware methods**: Always use `InfoContext`, `ErrorContext`, etc. instead of `Info`, `Error` | ||
| - **Log within transactions**: Ensure logs are created while a transaction or span is active | ||
|
|
||
| ## Related Documentation | ||
|
|
||
| - <PlatformLink to="/logs/">Logs</PlatformLink> - Comprehensive logging setup | ||
| - <PlatformLink to="/tracing/instrumentation/custom-instrumentation/">Custom Instrumentation</PlatformLink> - Manual tracing setup | ||
| - [Slog Integration Guide](/platforms/go/guides/slog/) - Full Slog integration details | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h: This is quite confusing. I am atplatforms/go/guides/echo/tracing/instrumentation/echo/and it displays just some text, no code snippets etc. The reference to the tracing setup in the alert is fine, but redirect to the Echo Getting Started guide doesn't make much sense because if a person is trying to adopt Echo instrumentation, they already read the Quick Start, navigate to the Tracing > Instrumentation > Echo Integration, just to be redirected back to the Quick Start.As a user I would expect to get more details in the nested "Echo Integration" page. Not sure what the value of this page is. This applies to all integrations except the logging ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the problem is that the quickstart page already has the example of how to setup and verify that tracing instrumentation works for each integration, so it would be just duplication of the content.
As to the helpfulness of the page. The previous layout would be Echo -> Tracing -> Instrumentation, and then you would only see custom instrumentation in the sidebar, inferring that we don't auto instrument traces for echo. What do you feel that this page is missing/should have?