Skip to content

Add device and OS attributes to logs #4493

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

Merged
merged 17 commits into from
Jun 17, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Format code
  • Loading branch information
getsentry-bot committed Jun 16, 2025
commit 225e4a8b5f2f3d829eb92300df15ce64b378cab6
29 changes: 20 additions & 9 deletions sentry/src/main/java/io/sentry/logger/LoggerApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,30 +185,36 @@ private void captureLog(
}
if (i > 0) {
attributes.put(
"sentry.message.template", new SentryLogEventAttributeValue(SentryAttributeType.STRING, message));
"sentry.message.template",
new SentryLogEventAttributeValue(SentryAttributeType.STRING, message));
}
}

final @Nullable SdkVersion sdkVersion = scopes.getOptions().getSdkVersion();
if (sdkVersion != null) {
attributes.put(
"sentry.sdk.name", new SentryLogEventAttributeValue(SentryAttributeType.STRING, sdkVersion.getName()));
"sentry.sdk.name",
new SentryLogEventAttributeValue(SentryAttributeType.STRING, sdkVersion.getName()));
attributes.put(
"sentry.sdk.version",
new SentryLogEventAttributeValue(SentryAttributeType.STRING, sdkVersion.getVersion()));
}

final @Nullable String environment = scopes.getOptions().getEnvironment();
if (environment != null) {
attributes.put("sentry.environment", new SentryLogEventAttributeValue(SentryAttributeType.STRING, environment));
attributes.put(
"sentry.environment",
new SentryLogEventAttributeValue(SentryAttributeType.STRING, environment));
}
final @Nullable String release = scopes.getOptions().getRelease();
if (release != null) {
attributes.put("sentry.release", new SentryLogEventAttributeValue(SentryAttributeType.STRING, release));
attributes.put(
"sentry.release", new SentryLogEventAttributeValue(SentryAttributeType.STRING, release));
}

attributes.put(
"sentry.trace.parent_span_id", new SentryLogEventAttributeValue(SentryAttributeType.STRING, spanId));
"sentry.trace.parent_span_id",
new SentryLogEventAttributeValue(SentryAttributeType.STRING, spanId));

if (Platform.isJvm()) {
setServerName(attributes);
Expand All @@ -225,11 +231,14 @@ private void setServerName(
final @Nullable String optionsServerName = options.getServerName();
if (optionsServerName != null) {
attributes.put(
"server.address", new SentryLogEventAttributeValue(SentryAttributeType.STRING, optionsServerName));
"server.address",
new SentryLogEventAttributeValue(SentryAttributeType.STRING, optionsServerName));
} else if (options.isAttachServerName()) {
final @Nullable String hostname = HostnameCache.getInstance().getHostname();
if (hostname != null) {
attributes.put("server.address", new SentryLogEventAttributeValue(SentryAttributeType.STRING, hostname));
attributes.put(
"server.address",
new SentryLogEventAttributeValue(SentryAttributeType.STRING, hostname));
}
}
}
Expand All @@ -243,11 +252,13 @@ private void setUser(final @NotNull HashMap<String, SentryLogEventAttributeValue
}
final @Nullable String username = user.getUsername();
if (username != null) {
attributes.put("user.name", new SentryLogEventAttributeValue(SentryAttributeType.STRING, username));
attributes.put(
"user.name", new SentryLogEventAttributeValue(SentryAttributeType.STRING, username));
}
final @Nullable String email = user.getEmail();
if (email != null) {
attributes.put("user.email", new SentryLogEventAttributeValue(SentryAttributeType.STRING, email));
attributes.put(
"user.email", new SentryLogEventAttributeValue(SentryAttributeType.STRING, email));
}
}
}
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy