Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Add top level support for logging #130

Open
savaki opened this issue Jun 30, 2018 · 10 comments
Open

Add top level support for logging #130

savaki opened this issue Jun 30, 2018 · 10 comments

Comments

@savaki
Copy link

savaki commented Jun 30, 2018

In addition to metrics and traces, opencensus should also include support for logging. Tags are an incredibly useful feature and being able to share a common set of tags across metrics and logging is incredibly useful not to mention the ability to correlate logs with traces as referenced here:

#123

@codefromthecrypt
Copy link

codefromthecrypt commented Jun 30, 2018 via email

@songy23
Copy link
Contributor

songy23 commented Jul 2, 2018

/cc @g-easy @sebright

@savaki
Copy link
Author

savaki commented Jul 16, 2018

Using go as a frame of reference, what I'd love to see is a trace and tag aware logging interface that can be implemented by different providers.

We use opencensus-go internally and have written an internal library to handle this that we've found to be exceptionally useful. Being able to filter log records by a particular user or org make troubleshooting much easier. This is even more magical when coupled with the log tailing feature of Stackdriver.

To move the conversation forward, I put together a working experiment of what this library might look like, https://github.com/savaki/opencensus-go/tree/logging/log Like sl4j, this log package is an interface without an implementation. In go, I'd expect exporters would be written for logrus, zap, and other popular packages

In languages like Java, I would imagine we would want to make available exporters for common packages like sl4j or log4j

@codefromthecrypt
Copy link

Thanks for the info. so this sounds like a primary interface for logging, then. Ex user code would use it directly instead of another library. Would you expect this only to be the case in languages where there is no dominant logging library? Ex in java would you expect folks to use something like this instead of SLF4J or log4j2 etc? Or would you use an integration pattern there instead

(asking the more general question as this is a spec repo so seemingly cross language)

@savaki
Copy link
Author

savaki commented Jul 17, 2018

That's a good question.

As I understand it, one of the main value propositions of OpenCensus is that it provides standard interface for common operational operations like tracing and metrics across many languages and many service providers. When I write to the OpenCensus API, I have the promise of portability between the supported providers. It's reasonably easy to swap out Zipkin for Stackdriver for example.

The intent of this proposal is to extend that promise to logging. Disclaimer: I'm not very familiar with the OC Java implementation. That said, it seems that if we want to allow users to integrate logging an existing Java app with OC, there are a number of approaches.

Configuration Only
In this approach, no code changes are required. All the magic would be done inside the SLF4J or log4j2 configuration using a custom appender like thing. I'm a little confused as to how this would work as I understand propagating ThreadLocal data over futures is still an outstanding issue. And if developers haven't changed their code and they don't have access to ThreadLocal data, I'm not sure how OC would get trace or tag data. Granted you could give a big disclaimer that this approach only works with non-async code, but that doesn't seem like a good approach.

Custom Marker
In the case of SLF4J, it looks like the have this Marker thing that might be appropriated for OpenCensus use. I haven't used it myself so I'm only guessing based on the apidoc. In this case, where ever we want the addition trace/tag data, we'd need the developer to inject an OC aware Marker. And given there may be existing code, it seems reasonable to expect OC to have to support wrapping existing Markers. I also need extend SLF4J to support OC configurations so swapping providers becomes a little more difficult. And while this seems like it ties OC to SLF4J, given the wide adoption of these libraries, for Java, I understand something like this might be the way to go.

Primary Interface
However, if the developer already has to modify the code where ever they would like to get this augmented data, why not provide a common interface and have them write to that? The would be no messy interaction between OC and existing marker like types. Swapping providers would be easier. The common interface could still write out to log4j.

I'm not a Java expert, so I certainly admit I could be missing something.

@codefromthecrypt
Copy link

codefromthecrypt commented Jul 17, 2018 via email

@ptone
Copy link

ptone commented Apr 19, 2019

Finding this issue in search of an open-census opinion on logging.

I think a point of value of open-census is a nice decoupling from platform implementation. So metrics instrumentation can work with multiple backends. The same could be applied to logging in way that logrus has done for golang (eg I wrote a stackdriver logging plugin for logrus - stackrus). But logrus is golang centric, while open-census is polyglot. If a large team wanted to adopt a standard logging framework, and then leave infrastructure implementation up to a platform team, open-census seems like a good project to provide that decoupling. (correlation to traces is a bonus, but different thing)

@otoolep
Copy link

otoolep commented Apr 22, 2019

CC @c24t @mtwo

@otoolep
Copy link

otoolep commented Apr 22, 2019

@c24t @mtwo -- see #130 (comment) above.

@mtwo
Copy link
Contributor

mtwo commented Apr 25, 2019

@ptone this is something that we're very interested in, and @c24t is working on some prototypes in Python. We wrote a plan a few months ago describing our goals and current thinking - feel free to comment or suggest edits (open it, apply for comment access, I'll grant it).

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

No branches or pull requests

7 participants