|
| 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. |
0 commit comments