elastic / elastic/apm-agent-java
Allow adding transaction context fields via Public API
- Lenguaje dominante
- Java
- Estrellas
- 594
- Forks
- 338
- Merge medio
- 1 d 13 h
- PR fusionados (30 d)
- 25
Descripción
**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.
Guía de contribución
Línea de trabajo
Empieza leyendo la Public API relacionada con Transaction#addTag y compárala con el método Transaction#addContext solicitado. Confirma cómo se representan los campos de contexto de request y user, y determina las pruebas necesarias para demostrar que los valores establecidos mediante la Public API aparecen en las secciones de contexto correspondientes, en lugar de aparecer únicamente bajo Tags.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- api, backend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 30/100