apm-agent-php icon indicating copy to clipboard operation
apm-agent-php copied to clipboard

Change the HTTP Request default span name

Open aguimaraes opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe. Most of our HTTP requests coming from outside the perimeter are going through an API Gateway. Since the default HTTP request instrumentation uses the schema <method> <host> to name spans, we end up with multiple calls like GET api.example.com without being able to easily differentiate between the different endpoints we are calling. When we need to quickly identify a problem with individual calls, it becomes hard exercise quickly.

Describe the solution you'd like I would like to be able to change the default span name for HTTP requests on initialisation time using an environment variable or a php.ini param.

Describe alternatives you've considered We could also change the default schema to use <method> <path> instead and we would start to see: GET api.example.com/user/333.

Additional context Current Spec suggests the same naming schema: https://github.com/elastic/apm/blob/main/specs/agents/tracing-instrumentation-http.md

aguimaraes avatar Jun 11 '23 10:06 aguimaraes

Hey @aguimaraes

For transactions (incoming http requests) we're using path as transaction name For outgoing spans (like curl requests) we using method and host as a span name

Could you please clarify what you would like to see in span and transaction name?

Regards, Pawel

intuibase avatar Jan 09 '24 09:01 intuibase

hey @intuibase, thank you for the reply. I want to be able to change the default name with an environment variable. e.g. I would like to add the path for the outgoing spans since everything goes to an API gateway and every request looks the same.

aguimaraes avatar Jan 09 '24 12:01 aguimaraes

Hi @aguimaraes

For now we don't have such feature planned near term but as a potential workaround we can propose transforming data with custom ingest pipelines. Spans for outgoing HTTP requests have URL in their context so it can be used to create a new name.

In the future we plan to allow registering a span processors (as PHP callable-s) at agent level that will allow modifying spans before they sent out - will this approach be useful to you?

SergeyKleyman avatar Jan 16 '24 09:01 SergeyKleyman

yes @SergeyKleyman, the future approach would work perfectly for our use case. Thanks for the workaround suggestion too! Have a great day!

aguimaraes avatar Jan 16 '24 10:01 aguimaraes