elastic / elastic/apm-agent-java
Get user in ElasticSearch REST client instrumentation
- Lingua principale
- Java
- Stelle
- 594
- Fork
- 338
- Merge medio
- 1g 13h
- PR unite (30g)
- 25
Descrizione
The way I found to do that is through looking into some Apache HTTP internals. This info is stored at `org.apache.http.impl.nio.client.InternalHttpAsyncClient#credentialsProvider`.
One way to get it is in our current instrumentation of `org.elasticsearch.client.RestClient#performRequest(org.elasticsearch.client.Request)` through the `client` field (that needs to be casted to a specific Apache HTTP implementation):
The problem with this approach is that we will need to add very specific dependency on Apache HTTP client code to an ES client instrumentation. This means we need to take extra caution measures to make sure user code using ES client is not failing linkage because ES client changed HTTP client implementation (for example if while instrumenting the user class, ByteBuddy added a reference to a non-existing Apache HTTP client class to the constant pool).
Another option is to add a second instrumentation specific to Apache HTTP client (possibly at `org.apache.http.impl.nio.client.InternalHttpAsyncClient#execute()`) that will be invoked within the existing and active ES client span, to get the active span and just set the user:
This approach is probably much safer, we just need to see that it works out properly with async client requests as well (#263)
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia leggendo la strumentazione esistente di org.elasticsearch.client.RestClient#performRequest(org.elasticsearch.client.Request), quindi confrontala con la strumentazione proposta di org.apache.http.impl.nio.client.InternalHttpAsyncClient#execute(). Controlla l’issue #263 per il comportamento delle richieste del client asincrono; il lavoro è completato quando lo span Elasticsearch attivo riceve l’utente senza introdurre una dipendenza diretta non sicura dal client HTTP Apache.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java
- Ambito
- observability-sre
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100