-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to change transaction name #99
Conversation
src/request.rs
Outdated
@@ -332,3 +332,14 @@ fn finish_request_context(request_id: Option<i64>, status_code: i32) -> crate::R | |||
|
|||
Ok(()) | |||
} | |||
|
|||
pub fn skywalking_set_request_name(args: &mut [ZVal]) -> phper::Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operation name
is the official term for the span. Why is this called request name
? We don't have this concept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to skywalking_set_operation_name
@olerapx Therefore, if you want to change the |
That would involve parsing the incoming GraphQL query, which feels out of scope for the project. I can, of course, use something like https://docs.rs/graphql-parser/latest/graphql_parser/ and extract operation name from the query, but I think it's more appropriate to leave for the usercode to handle. The function can be applied not only for GraphQL, sure. That's the point: if the currently provided mechanism of constructing the operation name is not suitable for any particular project, it can be customized from PHP without the need of modifying the skywalking-php further :) The idea is to make something similar that New Relic or Atatus provide: both services can detect operation name and give the ability to set it manually. |
The side effect of exposing and using this API in your app code, would make your app can't run w/o agent codes. Such as when you face performance impact of extra payload or/and in some circumstances. |
That can be mitigated with a simple I think, it should just be mentioned somewhere in the docs. |
Generally, if you refer to our Java agent implementation(go agent are going to have this as well), https://skywalking.apache.org/docs/skywalking-java/next/en/setup/service-agent/java-agent/application-toolkit-tracer/, we recommend you to build a toolkit lib with empty implementation and make sure they are harmless. Your codes should always use the toolkit lib without concerns, and the agent would instrument those APIs when the agent installed. This is better to add many IF/ELSE in your app codes. |
Do you mean creating a PHP library wrapping the |
You could check things in Java, https://github.com/apache/skywalking-java/blob/main/apm-application-toolkit/apm-toolkit-trace/src/main/java/org/apache/skywalking/apm/toolkit/trace/ActiveSpan.java |
It is not recommended to use extension functions, as discussed above, when |
|
For php-fpm, env is request context. |
OK, if that is the case, it should be good to use it as a bridge between app codes and agent kernel. |
Close as no active for months. |
Add a PHP function to change transaction name from user code.
This is useful if a PHP project uses GraphQL API. In that case, all requests will be routed through a single endpoint (that is, /graphql), and it becomes impossible to group requests based on endpoint parameters, such as in the REST API case