Skip to content

Conversation

@giortzisg
Copy link
Collaborator

@giortzisg giortzisg commented May 13, 2025

DESCRIBE YOUR PR

adding initial logs page for the Go SDK.

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.

  • Urgent deadline (GA date, etc.): May 15

@giortzisg giortzisg self-assigned this May 13, 2025
@vercel
Copy link

vercel bot commented May 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 15, 2025 10:13am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview May 15, 2025 10:13am
develop-docs ⬜️ Ignored (Inspect) Visit Preview May 15, 2025 10:13am

@cleptric cleptric requested a review from a team May 13, 2025 09:27
@codecov
Copy link

codecov bot commented May 13, 2025

Bundle Report

Changes will increase total bundle size by 147 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 11.19MB 153 bytes (0.0%) ⬆️
sentry-docs-client-array-push 9.51MB -6 bytes (-0.0%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: sentry-docs-server-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
1729.js -3 bytes 1.75MB -0.0%
../instrumentation.js -3 bytes 1.08MB -0.0%
9523.js -3 bytes 1.05MB -0.0%
../app/[[...path]]/page.js.nft.json 54 bytes 394.8kB 0.01%
../app/platform-redirect/page.js.nft.json 54 bytes 394.71kB 0.01%
../app/sitemap.xml/route.js.nft.json 54 bytes 392.68kB 0.01%
view changes for bundle: sentry-docs-client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
static/chunks/pages/_app-*.js -3 bytes 868.7kB -0.0%
static/chunks/8165-*.js -3 bytes 410.1kB -0.0%
static/4Y-*.js (New) 578 bytes 578 bytes 100.0% 🚀
static/4Y-*.js (New) 77 bytes 77 bytes 100.0% 🚀
static/3UUPLYm3C4-*.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️
static/3UUPLYm3C4-*.js (Deleted) -578 bytes 0 bytes -100.0% 🗑️

Comment on lines 47 to 49
The `Sentry.Logger` API exposes methods that support six different log levels: `trace`,
`debug`, `info`, `warn`, `error` and `fatal`. The methods support both `fmt.Print` and `fmt.Println` like syntax. Using
these methods is as simple as:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `Sentry.Logger` API exposes methods that support six different log levels: `trace`,
`debug`, `info`, `warn`, `error` and `fatal`. The methods support both `fmt.Print` and `fmt.Println` like syntax. Using
these methods is as simple as:
The `Sentry.Logger` API exposes methods that support six different log levels: `trace`,
`debug`, `info`, `warn`, `error` and `fatal`. The methods support both `fmt.Print` and `fmt.Printf` like syntax.
If you pass in format specifiers like `%v`, these will be sent to Sentry, and can be searched from within the Logs UI, and even added to the Logs views as a dedicated column.

Comment on lines 60 to 61
Additionally, you can attach properties to each log entry using the `attribute` API. These properties will be sent
to Sentry, and can be searched from within the Logs UI, and even added to the Logs views as a dedicated column.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Additionally, you can attach properties to each log entry using the `attribute` API. These properties will be sent
to Sentry, and can be searched from within the Logs UI, and even added to the Logs views as a dedicated column.
You can also pass additional attributes to the logger via the `SetAttributes` function. These attributes will also be searchable in the Logs UI.

Comment on lines 111 to 113
However in order to properly attach the correct Spans with each Log entry, a `context.Context` is required. The `Write` function of
the `io.Writer` interface does not provide `context` so currently wrapping the custom logger will provide limited functionality.
The recommended way is to use the `sentry.Logger` itself.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
However in order to properly attach the correct Spans with each Log entry, a `context.Context` is required. The `Write` function of
the `io.Writer` interface does not provide `context` so currently wrapping the custom logger will provide limited functionality.
The recommended way is to use the `sentry.Logger` itself.
In order to properly attach the correct trace with each Log entry, a `context.Context` is required. The `Write` function of
the `io.Writer` interface does not provide `context` so wrapping the custom logger will not get the trace and current span attached.
We recommend using the `sentry.Logger` to ensure your logs are connected to spans and errors in the Sentry UI.


### Debug

If debug is set to true, calls to the logger will also print to the console with the appropriate log level.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If debug is set to true, calls to the logger will also print to the console with the appropriate log level.
If the `Debug` init option is set to true, calls to the `sentry.Logger` APIs will also print to the console with the appropriate log level.

@@ -0,0 +1,143 @@
---
title: Set Up Logs
Copy link
Contributor

@coolguyzone coolguyzone May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title: Set Up Logs
title: Set Up Logs in Go

---
title: Set Up Logs
sidebar_title: Logs
description: "Structured logs allow you to send, view and query logs sent from your applications within Sentry."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: "Structured logs allow you to send, view and query logs sent from your applications within Sentry."
description: "Structured logs allow you to send, view, and query logs sent from your applications within Sentry."

logger.Warnf(ctx, "I have params: %v and attributes", "example param")
}
```
Currently the `attribute` API supports only these value types: `int`, `string`, `bool` and `float`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Currently the `attribute` API supports only these value types: `int`, `string`, `bool` and `float`.
Currently the `attribute` API supports only these value types: `int`, `string`, `bool`, and `float`.


<Alert>
In order to properly attach the correct trace with each Log entry, a `context.Context` is required. The `Write` function of
the `io.Writer` interface does not provide `context` so wrapping the custom logger will not get the trace and current span attached.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the `io.Writer` interface does not provide `context` so wrapping the custom logger will not get the trace and current span attached.
the `io.Writer` interface doesn't provide `context`, so wrapping the custom logger will not get the trace and current span attached.

Copy link
Contributor

@coolguyzone coolguyzone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for adding 🕺

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cleptric cleptric merged commit e19380c into master May 15, 2025
13 checks passed
@cleptric cleptric deleted the go-logs branch May 15, 2025 11:29
@github-actions github-actions bot locked and limited conversation to collaborators May 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants