elastic / elastic/apm-agent-java

Allow adding transaction context fields via Public API

Aperta
#433 9 commenti 1 reazione 0 assegnatari Vedi su GitHub
agent-java
Lingua principale
Java
Stelle
594
Fork
338
Merge medio
1g 13h
PR unite (30g)
25

Descrizione

**Describe the solution you'd like**
I would like for the Public API to support setting transaction context fields such as 'context.request.url.pathname' and 'context.user.user-agent' for transactions created via the Public API. Currently the Public API does not expose a way to set this information. This would be useful when integrating frameworks outside of the supported list (I'm currently in progress of trying to integrate Clojure's ring)

For me, the best solution would be to have a `Transaction#addContext` method in similar fashion as we have `Transaction#addTag`

```
Transaction tx = ElasticApm.startTransaction();
tx.addContext("request.url.pathname", "/hello");
tx.addContext("user.user-agent", "some-client");
```

Another option would be to add separate setters for each context field described here: https://www.elastic.co/guide/en/apm/server/current/exported-fields-apm.html#_context_fields but I feel having a single `addContext` would be the easiest to maintain over time.

**Describe alternatives you've considered**
I'm currently falling back to using `Transaction#addTag` to add this information to transactions. This works, but Kibana shows the information as a just flat list of key value pairs under "Tags". The Normally, `context.request.*` fields would be shown under "Request" tab with somewhat nicer presentation.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.