Skip to content
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

Nested labels are indexed as [object Object] #4096

Open
1 of 3 tasks
afharo opened this issue Jun 20, 2024 · 1 comment
Open
1 of 3 tasks

Nested labels are indexed as [object Object] #4096

afharo opened this issue Jun 20, 2024 · 1 comment

Comments

@afharo
Copy link
Member

afharo commented Jun 20, 2024

Describe the bug

When the agent is set up with nested global labels:

  • ELASTIC_APM_GLOBAL_LABELS=myObject.myKeyA=A,myObject.myKeyB.mySubKeyB=B
  • The same applies if using globalLabels in the init config.

The resulting indexed transaction looks like labels.myObject: [object Object].

In comparison, the Go agent indexes the transaction with labels.myObject_myKeyA: A and labels.myObject_myKeyB_mySubKeyB: B.

To Reproduce

Steps to reproduce the behavior:

  1. Use this config ELASTIC_APM_GLOBAL_LABELS=myObject.myKeyA=A,myObject.myKeyB.mySubKeyB=B (or via globalLabels in the init config.
  2. Report a few transactions
  3. Take a look at the transaction metadata
  4. See labels.myObject: [object Object]

Expected behavior

I'd expect parity with what other agents do. The Go client replaces the dots with underscores to flatten the labels.

Also, the apm.setLabel and apm.addLabel APIs suggest that the dots are replaced with underscores (docs).

Environment (please complete the following information)

Not relevant

How are you starting the agent? (please tick one of the boxes)

  • Calling agent.start() directly (e.g. require('elastic-apm-node').start(...))
  • Requiring elastic-apm-node/start from within the source code
  • Starting node with -r elastic-apm-node/start

Additional context

Agent config options:

Click to expand

As logged by the agent:

{"log.level":"info","@timestamp":"2024-06-20T16:37:50.649Z","log.logger":"elastic-apm-node","ecs.version":"8.10.0","agentVersion":"4.7.0","env":{"pid":37023,"proctitle":"/Users/afharo/.nvm/versions/node/v20.13.1/bin/node","os":"darwin 23.5.0","arch":"arm64","host":"ip-192-168-86-178.eu-central-1.compute.internal","timezone":"UTC+0200","runtime":"Node.js v20.13.1"},"config":{"active":{"source":"start","value":true},"breakdownMetrics":{"source":"start","value":true},"centralConfig":{"source":"start","value":false},"contextPropagationOnly":{"source":"start","value":true},"environment":{"source":"start","value":"development"},"globalLabels":{"source":"start","value":[["kibana_uuid","5b2de169-2785-441b-ae8c-186a1936b17d"],["git_rev","41883488bc4"],["myObject",{"keyA":"A","keyB":{"subKeyB":"B"}}]],"sourceValue":{"kibana_uuid":"5b2de169-2785-441b-ae8c-186a1936b17d","git_rev":"41883488bc4","myObject":{"keyA":"A","keyB":{"subKeyB":"B"}}}},"logLevel":{"source":"default","value":"info","commonName":"log_level"},"metricsInterval":{"source":"start","value":30,"sourceValue":"30s"},"serverUrl":{"source":"start","value":"https://kibana-cloud-apm.apm.us-east-1.aws.found.io/","commonName":"server_url"},"transactionSampleRate":{"source":"start","value":1,"commonName":"transaction_sample_rate"},"captureSpanStackTraces":{"source":"start","sourceValue":false},"secretToken":{"source":"start","value":"[REDACTED]","commonName":"secret_token"},"serviceName":{"source":"environment","value":"kibana","commonName":"service_name"},"serviceVersion":{"source":"start","value":"8.15.0","commonName":"service_version"}},"activationMethod":"require","message":"Elastic APM Node.js Agent v4.7.0"}

package.json dependencies:

Click to expand
"elastic-apm-node": "^4.7.0",
@afharo
Copy link
Member Author

afharo commented Jun 20, 2024

For extra context, I noticed that changing the config to

- {"kibana_uuid":"5b2de169-2785-441b-ae8c-186a1936b17d","git_rev":"41883488bc4","myObject":{"keyA":"A","keyB":{"subKeyB":"B"}}}}
+ {"kibana_uuid":"5b2de169-2785-441b-ae8c-186a1936b17d","git_rev":"592aafcaba2","myObject.keyA":"A","myObject.keyB.subKeyB":"B"}}

Solves the issue (it automatically applies the underscore conversion)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant