Giter Site home page Giter Site logo

Comments (4)

hagbard avatar hagbard commented on May 10, 2024

Ahh ha. You've been exploring the innards then :)

Yes, for a while there was no public API for setting them and they were an internal implementation detail (a way to pass structured data in a mostly safe way from frontend to backend). Since they got used more and more, I decided to expose a "with()" method for setting them, along with using strongly typed keys. However since this was a bit experimental I put it in the Google extension API, not the core API (at least until we were sure it was working as intended).

It can be easily promoted into the core API if it would help (and if you have any feedback on it and how it works, please let me know). See:
https://github.com/google/flogger/blob/master/google/src/main/java/com/google/common/flogger/GoogleLoggingApi.java

You could, as a test, use the GoogleLogger and the "with()" method in its API to set tags.

from flogger.

hagbard avatar hagbard commented on May 10, 2024

I'm looking again at backends and adding a log4j2 backend. Since you mentioned "MDC" (of which I know nothing) I was wondering if you wanted to discuss what that was and how you thought it might work well with Flogger's Metadata. I'd be happy to look at adding it (especially if it can leave metadata more structured when it's handled by the backend).

from flogger.

Maaartinus avatar Maaartinus commented on May 10, 2024

I know nothing about Metadata., but to me, MDC looks very different. MDC is basically just a public static final ThreadLocal<Map<String, String>>, which you put something in when you start some processing (and remove it afterwards) and - depending on the configuration - it gets printed with every log line automatically. Pretty trivial and pretty useful. I guess, it works with flogger when using a corresponding backend.

from flogger.

deadmoose avatar deadmoose commented on May 10, 2024

I've got something cobbled together on my end using a io.grpc.Context and a custom logging backend to do similar. IIRC we'd had mixed luck with MDC because it's very thread-oriented, so it started falling apart for more complicated systems (e.g. we wanted breadcrumbs about the RPC that caused some complex multi-threaded code)

Unfortunately, it's a little awkward arbitrarily dealing with grpc Contexts & core flogger isn't going to want to pull in that kind of dependency. But maybe a way to teach flogger about arbitrary metadata suppliers would simplify doing something like that without going to the extreme of a custom backend?

from flogger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.