-
Notifications
You must be signed in to change notification settings - Fork 38
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
Add logging API to the SDK #159
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though it's nice to have the symmetry for L as we do for M, E, and T, I don't think this is the right approach. It doesn't seem useful not being integrated with any logging framework, and I think it looks at "logs as telemetry" instead of "application logs as one set of logs in an application stack".
When we implemented logs-in-context, there was a lot of debate about whether the agent should just send the log messages or we should rely on something else to do it. Matt Culmone, one of the Log PMs, was adamant that the application should not be posting logs to an HTTP endpoint. There are existing solutions for this, like log forwarders, that do a far better job batching, scanning, rewinding, etc across multiple services and multiple sources than we ever could. If the user wants to consume any other type of logging, like access logs or nginx logs or non-Java logs, they would still need a log forwarder.
Before shipping this implementation, I'd encourage you to reach out to Matt or Rebecca Holzschuh to understand what they'd recommend.
telemetry_core/src/main/java/com/newrelic/telemetry/SenderConfiguration.java
Outdated
Show resolved
Hide resolved
telemetry_core/src/main/java/com/newrelic/telemetry/SenderConfiguration.java
Outdated
Show resolved
Hide resolved
telemetry_core/src/main/java/com/newrelic/telemetry/SenderConfiguration.java
Outdated
Show resolved
Hide resolved
telemetry_core/src/main/java/com/newrelic/telemetry/SenderConfiguration.java
Outdated
Show resolved
Hide resolved
telemetry_core/src/main/java/com/newrelic/telemetry/SpanBatchSenderFactory.java
Outdated
Show resolved
Hide resolved
telemetry_core/src/main/java/com/newrelic/telemetry/logs/Log.java
Outdated
Show resolved
Hide resolved
telemetry_core/src/main/java/com/newrelic/telemetry/logs/Log.java
Outdated
Show resolved
Hide resolved
logger.debug( | ||
"Sending a log batch (number of logs: {}) to the New Relic log ingest endpoint)", | ||
batch.size()); | ||
String json = marshaller.toJson(batch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to rethink the sender if we're going to implement this as-is. If the sender does literally any logging you could quickly drown yourself in recursive logs without careful configuration. Think about audit logging:
- There's an http post.
- There's a log message with the contents of the post.
- There's an http post with the log message with the contents of the post.
- There's a log message with the contents of the post with the log message with the contents of the post.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no expectation that this code would be used as the API for a full-fledged logging implementation, so I don't think this is a concern.
Hi Jeff. My use-case for this is not acting as the primary API for logging implementations. This is to support some log-like features of OpenTelemetry. In particular, the events that can be attached to Spans are being used to log information about the processing of a given span. I'd like to experiment with writing them as log entries using the logging API. I discussed this with Rebecca and she agreed. |
@jeffalder note, my use-case for this is supporting the "embedded" log model being discussed here: open-telemetry/opentelemetry-specification#622 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I'm in favor of the concept. If we're providing an HTTP endpoint to send logs to, it only makes sense that we'd include functionality to use that endpoint in our telemetry SDKs.
Before we go through with this, I'd like to see the exporter specs and the telemetry SDK specs updated to match.
ByteArrayOutputStream bytes = new ByteArrayOutputStream(); | ||
e.printStackTrace(new PrintStream(bytes)); | ||
this.message = bytes.toString(); | ||
this.logType = "stackTrace"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a convention?
If so, it doesn't align with our other logging error semantics, here: https://github.com/newrelic/newrelic-exporter-specs/tree/master/logging#errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooh! I totally forgot there were semantics already designed for some of this stuff. Will address!
Chicken and egg! I don't think we'd want to update the exporter specs until we've actually got an exporter using this and it's the officially sanctioned way to send span events (or whatever). Telemetry SDK, though, yes. Should we get this at least merged before we spend time writing specs for it, pre-release? |
telemetry_core/src/main/java/com/newrelic/telemetry/logs/json/LogJsonCommonBlockWriter.java
Outdated
Show resolved
Hide resolved
I don't see any new tests here, and it looks like this is ready to merge. There's so much code cloned from the span side because the API shapes are so similar. Can you explain why they're cloned? |
I need to add tests; just realized that there are a lot missing still. I'll be doing that ASAP. The code is cloned because I was moving fast to get something working. After this gets merged, I think that's definitely something to figure out how to unify. |
Co-authored-by: jeffalder <49817386+jeffalder@users.noreply.github.com>
…LogJsonCommonBlockWriter.java Co-authored-by: jeffalder <49817386+jeffalder@users.noreply.github.com>
add a log integration test
ok, added tests for json generation, and an integration test. Also got the attribute names in line with the exporter specs for logs. |
We already have a backlog of 16 tickets. Are you suggesting just tacking on more to the backlog? That is an issue that will never get done because it's tedious housekeeping. I feel like this is how tech debt becomes overwhelming, and we have reactions like "if we had just done this at the time ..." I feel we have a responsibility to maintain maximally clean code. Unless there's roadmap pressure to ship this that I'm not aware of? |
@jeffalder do you think that this PR should also include significant refactoring of unrelated code? Do you have specific examples of where you want things refactored? I feel like refactoring should happen in a separate PR from one that adds new functionality. |
|
This addition to the SDK will be useful for non-typical logging usages, such as reporting OpenTelemetry Span Events as log entries, in context. It's not intended as an API to be used to implement high-throughput logging systems. That use-case should be reserved for log forwarder implementations.