-
Notifications
You must be signed in to change notification settings - Fork 532
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
The best (possible) way to add custom attribute to the metric #1702
Comments
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
I've been looking for the same thing for opentelemetry-java. I wonder if this issue would be better off moving to a different opentelemetry project? (I'm not which, though!) |
I've found a solution to the problem I initially had. I was able to solve it in a bit different way than I intended from the very beginning. Problem:I am working on a project that is based on the Next.js framework. However, I'm using a custom Express server configuration. This configuration is based on the original Next.js custom server example and it sets "*" matcher for all the requests that come to Express to be handled by Next.js. My solution is using this small piece of code to set the proper import { getRPCMetadata, RPCType } from '@opentelemetry/core';
import { context } from '@opentelemetry/api';
// ...
// Override "*" http_route attribute set by Express instrumentation
const route = matcher.match(parsedUrl); // Get proper route
const rpcMetadata = getRPCMetadata(context.active());
if (rpcMetadata?.type === RPCType.HTTP) {
rpcMetadata.route = route;
} Basically, For the full reference, please take a look at another discussion thread. @hertzsprung, maybe this is something that can inspire you to find a similar solution for your problem. |
Maybe this shouldn't be closed? I would still very much like to see this implemented. I have a requirement to implement this but would only be possible with a custom attribute. Appending custom values to |
Is it possible to add a custom attribute to the standard metric? For example, I would like to extend
http_server_duration_bucket
by adding a custom tag. For example, is it possible to add a custom tag based on the request data, let's say I want to add a custom tag based on the query parameters coming in therequest
.I have a basic setup using Node.js and Express server, like:
Imagine I want to execute this request:
curl -s -X POST "http://localhost:4000/test?appVersion=1.1.1"
and I would like to expect metrics like:
Is there any way to do this?
I know that we need to carefully control custom attributes as this may drastically increase the amount of metrics. The request query parameter is just an example for simplification.
The text was updated successfully, but these errors were encountered: