-
In the code where metrics are recorded https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/http.ts#L814-L820 the And there is no way to add your own attributes. For us it would be nice if there was a request hook to inject our own attributes, such as "podRole" which can be "stable" or "canary", and actually change during life cycle of pod, so doing something at initialization is not good. Is there a deliberate reason why the metric attributes are not exposed for being extended by the user? Or am I just missing how it is done? Thankful for your help and feedback! 🙇 |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Hey, also looking for this functionality. Would be extremely useful if we could customize these attributes to suit our use cases. |
Beta Was this translation helpful? Give feedback.
-
Hey, it is something I need as well. I was playing around with |
Beta Was this translation helpful? Give feedback.
-
There is a PR open and it is in review! #4108 |
Beta Was this translation helpful? Give feedback.
-
I came across this issue when trying to add some additional attributes across all our metrics in some of my own services, and found it quite surprising that it wasn't supported by default in the Node.js SDK. The approach I ultimately ended up taking was to require that any additional custom attributes were defined in the resource, and then allowing the exporters to be extended with functionality that would copy over specific attributes from the resources as specified, see full implementation here: #5253 const openTelemetrySdk = new NodeSDK({
resource: new resources.Resource({
[ATTR_SERVICE_NAME]: "test-otel-app",
"deployment.environment.name": "production",
}),
metricReader: new PeriodicExportingMetricReader({
exporter: extendExporterWithResourceAttributes(
new ConsoleMetricExporter(),
new Set(["deployment.environment.name", "process.pid"])
),
}),
instrumentations: getNodeAutoInstrumentations(),
}); |
Beta Was this translation helpful? Give feedback.
We decided to solve this in otel config instead
otel-config.yaml