Skip to content

Commit 7136f13

Browse files
Add default attributes documentation for SDK logs across platforms
Co-authored-by: aprasad <[email protected]>
1 parent d49e1c1 commit 7136f13

File tree

20 files changed

+561
-0
lines changed

20 files changed

+561
-0
lines changed
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# SDK Logs Default Attributes Documentation Update
2+
3+
## Summary
4+
5+
This document summarizes the changes made to update all SDK documentation files that have logging support to indicate what attributes they set by default. The changes were made based on the information from the [Sentry Developer Documentation for Logs](https://develop.sentry.dev/sdk/telemetry/logs/#default-attributes).
6+
7+
## Changes Made
8+
9+
### 1. Created Default Attributes Platform Includes
10+
11+
Created a new directory `platform-includes/logs/default-attributes/` with specific files for each SDK:
12+
13+
- **JavaScript SDK** (`javascript.mdx`):
14+
- Core attributes: `sentry.environment`, `sentry.release`, `sentry.trace.parent_span_id`, `sentry.sdk.name`, `sentry.sdk.version`
15+
- Message template attributes: `sentry.message.template`, `sentry.message.parameter.X`
16+
- User attributes: `user.id`, `user.name`, `user.email`
17+
- **Browser-specific**: `browser.name`, `browser.version`
18+
- **Server-specific**: `server.address`
19+
20+
- **Python SDK** (`python.mdx`):
21+
- Core attributes: Standard SDK attributes
22+
- Message template attributes: For `{attribute_name}` placeholder syntax
23+
- User attributes: Standard user attributes
24+
- **Server-specific**: `server.address`
25+
26+
- **PHP SDK** (`php.mdx`):
27+
- Core attributes: Standard SDK attributes
28+
- Message template attributes: For format specifiers like `%s`
29+
- User attributes: Standard user attributes
30+
- **Server-specific**: `server.address`
31+
32+
- **Java SDK** (`java.mdx`):
33+
- Core attributes: Standard SDK attributes
34+
- Message template attributes: For format specifiers like `%s`
35+
- User attributes: Standard user attributes
36+
- **Server-specific**: `server.address`
37+
38+
- **Ruby SDK** (`ruby.mdx`):
39+
- Core attributes: Standard SDK attributes
40+
- Message template attributes: For format specifiers like `%s`
41+
- User attributes: Standard user attributes
42+
- **Server-specific**: `server.address`
43+
44+
- **Android SDK** (`android.mdx`):
45+
- Core attributes: Standard SDK attributes with `sentry.java.android` as sdk name
46+
- Message template attributes: For format specifiers
47+
- User attributes: Standard user attributes
48+
- **Mobile-specific**: `os.name`, `os.version`, `device.brand`, `device.model`, `device.family`
49+
50+
- **React Native SDK** (`react-native.mdx`):
51+
- Core attributes: Standard SDK attributes with `sentry.javascript.react-native` as sdk name
52+
- Message template attributes: For `logger.fmt` or format strings
53+
- User attributes: Standard user attributes
54+
- **Mobile-specific**: `os.name`, `os.version`, `device.brand`, `device.model`, `device.family`
55+
56+
- **Dart SDK** (`dart.mdx`):
57+
- Core attributes: Standard SDK attributes with `sentry.dart` or `sentry.dart.flutter` as sdk name
58+
- Message template attributes: For format specifiers
59+
- User attributes: Standard user attributes
60+
- **Mobile-specific** (Flutter): `os.name`, `os.version`, `device.brand`, `device.model`, `device.family`
61+
62+
- **Rust SDK** (`rust.mdx`):
63+
- Core attributes: Standard SDK attributes with `sentry.rust` as sdk name
64+
- Message template attributes: For format specifiers
65+
- User attributes: Standard user attributes
66+
- **Server-specific**: `server.address`
67+
68+
### 2. Updated SDK Documentation Files
69+
70+
Updated the following SDK documentation files to include the new "Default Attributes" section:
71+
72+
#### Files Using Platform Includes:
73+
- `docs/platforms/python/logs/index.mdx`
74+
- `docs/platforms/javascript/common/logs/index.mdx`
75+
- `docs/platforms/php/common/logs/index.mdx`
76+
- `docs/platforms/java/common/logs/index.mdx`
77+
- `docs/platforms/ruby/logs/index.mdx`
78+
- `docs/platforms/android/logs/index.mdx`
79+
- `docs/platforms/react-native/logs/index.mdx`
80+
- `docs/platforms/dart/guides/flutter/logs/index.mdx`
81+
82+
#### Files with Explicit Content:
83+
- `docs/platforms/go/common/logs/index.mdx` - Added detailed default attributes section
84+
- `docs/platforms/rust/common/logs/index.mdx` - Added detailed default attributes section
85+
86+
## Default Attributes by SDK Type
87+
88+
### Core Attributes (All SDKs)
89+
- `sentry.environment`: Environment set in SDK if defined
90+
- `sentry.release`: Release set in SDK if defined
91+
- `sentry.trace.parent_span_id`: Span ID of active span (only if there was an active span)
92+
- `sentry.sdk.name`: Name of the SDK that sent the log
93+
- `sentry.sdk.version`: Version of the SDK that sent the log
94+
95+
### Message Template Attributes (All SDKs)
96+
- `sentry.message.template`: The parameterized template string
97+
- `sentry.message.parameter.X`: Parameters to the template string
98+
99+
### User Attributes (All SDKs)
100+
- `user.id`: User ID
101+
- `user.name`: Username
102+
- `user.email`: Email address
103+
104+
### Backend SDKs (Node.js, Python, PHP, Ruby, Go, Java, etc.)
105+
- `server.address`: Address of the server that sent the log
106+
107+
### Browser SDKs (JavaScript in browser)
108+
- `browser.name`: Display name of the browser application
109+
- `browser.version`: Version string of the browser
110+
111+
### Mobile SDKs (Android, iOS, React Native, Flutter)
112+
- `os.name`: Name of the operating system
113+
- `os.version`: Version of the operating system
114+
- `device.brand`: Brand of the device
115+
- `device.model`: Model of the device
116+
- `device.family`: Family of the device
117+
118+
## Implementation Details
119+
120+
1. **Attribute Specificity**: Each SDK only mentions attributes relevant to its platform type. For example:
121+
- Browser attributes are only mentioned for JavaScript browser SDKs
122+
- Mobile device attributes are only mentioned for Android, React Native, and Flutter SDKs
123+
- Server attributes are only mentioned for backend SDKs
124+
125+
2. **Message Template Context**: Each SDK's default attributes documentation explains its specific message templating syntax:
126+
- JavaScript: `logger.fmt` or format strings
127+
- Python: `{attribute_name}` placeholder syntax
128+
- PHP/Java/Ruby: Format specifiers like `%s`
129+
- Go: Format specifiers like `%v`
130+
- Rust: Format syntax
131+
132+
3. **SDK Name Specificity**: Each SDK documents its specific `sentry.sdk.name` value:
133+
- JavaScript: `sentry.javascript.browser`, `sentry.javascript.node`, etc.
134+
- Python: `sentry.python`
135+
- PHP: `sentry.php`
136+
- Java: `sentry.java`
137+
- Android: `sentry.java.android`
138+
- React Native: `sentry.javascript.react-native`
139+
- Dart: `sentry.dart` or `sentry.dart.flutter`
140+
- Go: `sentry.go`
141+
- Ruby: `sentry.ruby`
142+
- Rust: `sentry.rust`
143+
144+
## SDKs Supported
145+
146+
All SDKs listed on the [Logs Getting Started page](https://docs.sentry.io/product/explore/logs/getting-started/) now have default attributes documentation:
147+
148+
### JavaScript (all variants)
149+
- Browser JavaScript, Angular, Astro, AWS Lambda, Azure Functions, Bun, Cloudflare, Connect, Electron, Ember, Express, Fastify, Gatsby, Google Cloud Functions, Hapi, Hono, Koa, Nest.js, Node.js, Next.js, Nuxt, React, React Router, Remix, Solid, SolidStart, Svelte, SvelteKit, TanStack Start, Vue, Wasm
150+
151+
### Java
152+
- Java, Spring, Spring Boot
153+
154+
### Mobile
155+
- Android, Flutter, React Native
156+
157+
### PHP
158+
- PHP, Laravel
159+
160+
### Python
161+
- Python
162+
163+
### Ruby
164+
- Ruby
165+
166+
### Go
167+
- Go
168+
169+
### Rust
170+
- Rust
171+
172+
This ensures that developers using any of these SDKs can now understand exactly what default attributes will be automatically attached to their log entries, helping them make better use of Sentry's structured logging capabilities.

docs/platforms/android/logs/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ With Sentry Structured Logs, you can send text based log information from your a
2525

2626
<PlatformContent includePath="logs/integrations" />
2727

28+
## Default Attributes
29+
30+
<PlatformContent includePath="logs/default-attributes" />
31+
2832
## Options
2933

3034
<PlatformContent includePath="logs/options" />

docs/platforms/dart/guides/flutter/logs/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ With Sentry Structured Logs, you can send text based log information from your a
2121

2222
<PlatformContent includePath="logs/usage" />
2323

24+
## Default Attributes
25+
26+
<PlatformContent includePath="logs/default-attributes" />
27+
2428
## Options
2529

2630
<PlatformContent includePath="logs/options" />

docs/platforms/go/common/logs/index.mdx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,39 @@ slogger.Info("Implementing slog.Logger")
128128

129129
We're actively working on adding more integration support for Logs. Currently, we are looking at adding support for [`zerolog`](https://pkg.go.dev/github.com/rs/zerolog). You can follow this [GitHub issue](https://github.com/getsentry/sentry-go/issues/1015) to track progress.
130130

131+
## Default Attributes
132+
133+
The Go SDK automatically sets several default attributes on all log entries to provide context and improve debugging:
134+
135+
### Core Attributes
136+
137+
- `sentry.environment`: The environment set in the SDK if defined
138+
- `sentry.release`: The release set in the SDK if defined
139+
- `sentry.trace.parent_span_id`: The span ID of the span that was active when the log was collected (only set if there was an active span)
140+
- `sentry.sdk.name`: The name of the SDK that sent the log (`sentry.go`)
141+
- `sentry.sdk.version`: The version of the SDK that sent the log
142+
143+
### Message Template Attributes
144+
145+
If the log was parameterized using format specifiers (like `%v`), the SDK will also set:
146+
147+
- `sentry.message.template`: The parameterized template string
148+
- `sentry.message.parameter.X`: The parameters to the template string, where X is the parameter's position
149+
150+
### User Attributes
151+
152+
If user information is available in the current scope:
153+
154+
- `user.id`: The user ID
155+
- `user.name`: The username
156+
- `user.email`: The email address
157+
158+
### Server Attributes
159+
160+
For backend applications:
161+
162+
- `server.address`: The address of the server that sent the log (equivalent to server_name attached to errors and transactions)
163+
131164
## Options
132165

133166
### BeforeSendLog
@@ -157,3 +190,5 @@ if err := sentry.Init(sentry.ClientOptions{
157190
### Debug
158191

159192
If the `Debug` init option is set to true, calls to the `sentry.Logger` will also print to the console with the appropriate log level.
193+
194+
```

docs/platforms/java/common/logs/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ With Sentry Structured Logs, you can send text based log information from your a
2525

2626
<PlatformContent includePath="logs/integrations" />
2727

28+
## Default Attributes
29+
30+
<PlatformContent includePath="logs/default-attributes" />
31+
2832
## Options
2933

3034
<PlatformContent includePath="logs/options" />

docs/platforms/javascript/common/logs/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ With Sentry Structured Logs, you can send text based log information from your a
3131

3232
<PlatformContent includePath="logs/integrations" />
3333

34+
## Default Attributes
35+
36+
<PlatformContent includePath="logs/default-attributes" />
37+
3438
## Options
3539

3640
<PlatformContent includePath="logs/options" />

docs/platforms/php/common/logs/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Let us know what you would like to see on GitHub: [Symfony Logs](https://github.
2727

2828
<PlatformContent includePath="logs/usage" />
2929

30+
## Default Attributes
31+
32+
<PlatformContent includePath="logs/default-attributes" />
33+
3034
## Options
3135

3236
<PlatformContent includePath="logs/options" />

docs/platforms/python/logs/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ With Sentry Structured Logs, you can send text based log information from your a
2525

2626
<PlatformContent includePath="logs/integrations" />
2727

28+
## Default Attributes
29+
30+
<PlatformContent includePath="logs/default-attributes" />
31+
2832
## Options
2933

3034
<PlatformContent includePath="logs/options" />

docs/platforms/react-native/logs/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ With Sentry Structured Logs, you can send text based log information from your a
2727

2828
<PlatformContent includePath="logs/integrations" />
2929

30+
## Default Attributes
31+
32+
<PlatformContent includePath="logs/default-attributes" />
33+
3034
## Options
3135

3236
<PlatformContent includePath="logs/options" />

docs/platforms/ruby/logs/index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ With Sentry Structured Logs, you can send text based log information from your a
2020
## Usage
2121

2222
<PlatformContent includePath="logs/usage" />
23+
24+
## Default Attributes
25+
26+
<PlatformContent includePath="logs/default-attributes" />

0 commit comments

Comments
 (0)