Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add Sentry Log feature to Java SDK #4372

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

adinauer
Copy link
Member

@adinauer adinauer commented May 6, 2025

📜 Description

Add API for capturing logs.

💡 Motivation and Context

Partial implementation for #4350

💚 How did you test it?

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

  • Rate limit
  • Buffering / Batching
  • Options
    • to enable/disable
    • beforeSend
    • sampleRate
  • more attributes

sentry.sdk.name: The name of the SDK that sent the log
sentry.sdk.version: The version of the SDK that sent the log
[BACKEND SDKS ONLY] server.address: The address of the server that sent the log. Equivalent to server_name we attach to errors and transactions.

Copy link
Contributor

github-actions bot commented May 6, 2025

Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

- Add Sentry Log feature to Java SDK ([#4372](https://github.com/getsentry/sentry-java/pull/4372))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description.

Generated by 🚫 dangerJS against 0627186

Comment on lines +31 to +32
// TODO SentryLevel.TRACE does not exists yet
// log(SentryLevel.TRACE, message, args);
Copy link
Member

@lcian lcian May 6, 2025

Choose a reason for hiding this comment

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

We should add this

throws IOException {
writer.beginObject();
writer.name("items").value(logger, items);
writer.endObject();
Copy link
Member

Choose a reason for hiding this comment

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

I think we are missing the serialization of unknown here

for (Object arg : args) {
final @NotNull String type = getType(arg);
attributes.put(
"sentry.message.parameters." + i, new SentryLogEventAttributeValue(type, arg));
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
"sentry.message.parameters." + i, new SentryLogEventAttributeValue(type, arg));
"sentry.message.parameter." + i, new SentryLogEventAttributeValue(type, arg));

logger.log(SentryLevel.ERROR, message, exception);
throw exception;
}

Copy link
Member

Choose a reason for hiding this comment

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

Level is also required

Copy link
Member

Choose a reason for hiding this comment

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

In that case it can probably become @NotNull on SentryLogEvent

Copy link
Member

@lcian lcian left a comment

Choose a reason for hiding this comment

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

Left some comments, otherwise LGTM as a first implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants