You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I need to get metadata container.id and/or host.name from APM Agent for my logger lib to link my logs with service in Kibana UI.
I've already added ...apmAgent.currentTraceIds() in logs, but not works as intended. For example, container.id or host.name required for logs to be shown in Logs tab in Kibana (thread).
I not have access or opportunity to add these variables in filebeat or something else outside of node application. My solutions will be dictated by this limitation.
Describe the solution you'd like
I suggest to create function apmAgent.getMetadata(), that will return object like this:
As far as I know, this filter should be invoked immediately after adding if agent is started. But still looks like bad solution in my opinion, because multiple calls will increase filter array and execution ticks for process these filters (memory leak opportunity).
Additional context
I repeat, that I do not have access or opportunity to add these variables in filebeat or something else outside of node application, I will appreciate solution in NodeJS application.
The text was updated successfully, but these errors were encountered:
There are no plans for adding new features to elastic-apm-node. The solution you're proposing is a good use case for the addMetadataFilter API and should be IMO it should be in the documentation.
But still looks like bad solution in my opinion, because multiple calls will increase filter array and execution ticks for process these filters (memory leak opportunity).
this is a good point and to avoid this problem we could modify a bit this code to not add a filter for each call to the function
// Hold references to metadata & a promise letapmMetadata=null;letmetadataResolve;letmetadataPromise=newPromise((resolve)=>{metadataResolve=resolve;});// Call filter only once at TOP level// - apmMetadata will be updated for every filter call// - the promise will resolve with the 1st value apm.addMetadataFilter((md)=>{apmMetadata=md;mdResolve(apmMetadata);returnmd;});// function will return last metadata or the promise for the 1st callasyncfunctiongetMetadata(){if(apmMetadata){returnapmMetadata;}returnmetadataPromise;}
Is your feature request related to a problem? Please describe.
I need to get metadata
container.id
and/orhost.name
from APM Agent for my logger lib to link my logs with service in Kibana UI.I've already added
...apmAgent.currentTraceIds()
in logs, but not works as intended. For example,container.id
orhost.name
required for logs to be shown inLogs
tab in Kibana (thread).I not have access or opportunity to add these variables in filebeat or something else outside of node application. My solutions will be dictated by this limitation.
Describe the solution you'd like
I suggest to create function
apmAgent.getMetadata()
, that will return object like this:It can be stored and updated in http-apm-client and proxied through Agent.
Describe alternatives you've considered
As temporary working solution, I ended up with using
addMetadataFilter
function like this:As far as I know, this filter should be invoked immediately after adding if agent is started. But still looks like bad solution in my opinion, because multiple calls will increase filter array and execution ticks for process these filters (memory leak opportunity).
Additional context
I repeat, that I do not have access or opportunity to add these variables in filebeat or something else outside of node application, I will appreciate solution in NodeJS application.
The text was updated successfully, but these errors were encountered: