Instrument SLF4J's addKeyValue(key, value) method from fluent API
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 38/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- azure, java
- Ambito
- observability
Direzione di ricerca
Inizia individuando l’instrumentazione fwi_java esistente per SLF4J MDC.put e confrontala con l’API fluent addKeyValue(key, value) di SLF4J. Traccia il percorso dei metadati dei log fino a customDimensions di Application Insights, quindi verifica che una chiamata di log fluent produca la voce chiave-valore nella tabella traces.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
At our project we have a bunch of azure function written in java. Those functions are connected to the application insight through the following env variables
APPLICATIONINSIGHTS_CONNECTION_STRING=...
APPLICATIONINSIGHTS_ENABLE_AGENT=true
In java code we use SLF4J and Logback libraries for logging. We often need to attach some metadata to our logs so it appears in customDimensions field in the traces table in application insights.
So far we have been doing this by using MDC from SLF4J, so the code is something alone these lines
MDC.put("key1", "val1");
log.info("my log message");
MDC.remove("key1");
The code above makes "my log message" having "key1" field in customDimensions field in traces table in application insights. Fine. That means that MDC.put() has been properly instrumented.
But recently we discovered more convenient way to attach those additional fields to the log message.
SLF4J provides fluent api https://www.slf4j.org/manual.html#fluent which exposes addKeyValue(key, val) method for doing that (instead of putting those key+val in MDC)
So the code above can be rewritten as following:
log.atInfo()
.addKeyValue("key1", "val1")
.log("my log message");
Looks much cleaner, doesn't it?
Unfortunately, in this case key1="val1" entry does not appear in the customDimensions of this log message in traces table in the application insights. That means fwi_java SDK does not instrument this addKeyValue() as it does for MDC.put().
From my point of view making .addKeyValue(key, val) instrumented similarly to MDC.put(key, val) would be the right move. They both have very similar semantics, but .addKeyValue(key, val) makes the code much cleaner.
- Lingua principale
- Java
- Stelle
- 327
- Fork
- 222
- Merge medio
- 22h 34m
- PR unite (30g)
- 14
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/ApplicationInsights-Java
-
microsoft/ApplicationInsights-Java#4851 · 1 assegnatario ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
microsoft/ApplicationInsights-Java#4817 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
microsoft/ApplicationInsights-Java#4770 · 2 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
microsoft/ApplicationInsights-Java#4769 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
microsoft/ApplicationInsights-Java#4729 · 121 commenti ·
Tutte le issue di microsoft/ApplicationInsights-Java
Issue simili
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
apache/flink-agents#1152 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
jenkinsci/blueocean-plugin#5417 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
objectionary/eo-graphs#75 ·