Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/platforms/go/guides/echo/tracing/instrumentation/echo.mdx
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.
Copy link
Member

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 at platforms/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.

Copy link
Collaborator Author

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?


## 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.
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 docs/platforms/go/guides/fiber/tracing/instrumentation/fiber.mdx
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 docs/platforms/go/guides/gin/tracing/instrumentation/gin.mdx
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 docs/platforms/go/guides/http/tracing/instrumentation/http.mdx
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 docs/platforms/go/guides/iris/tracing/instrumentation/iris.mdx
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 docs/platforms/go/guides/logrus/tracing/instrumentation/logrus.mdx
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
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 docs/platforms/go/guides/slog/tracing/instrumentation/slog.mdx
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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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
Loading
Loading