DataDog / dd-trace-js

JavaScript APM Tracer
https://docs.datadoghq.com/tracing/
Other
640 stars 303 forks source link

Enable sending custom tags with Playwright integration #2852

Closed declancarrollcb closed 11 months ago

declancarrollcb commented 1 year ago

Currently, when using the Datadog Trace integration with Playwright, it is not possible to send custom tags along with the traces. This is limiting the usefulness of the integration for our team, as we rely heavily on custom tags to categorize and filter our traces.

I would like to request the addition of a feature that enables users to send custom tags along with the Playwright integration. This could be achieved through the addition of a new configuration option or through a modification of the existing configuration options.

Currently for the JUnit upload it is possible to do the following:

test.info().annotations().put("dd_tags[test.requirement]", "RISK-009");

Is there a way to make the above work with the Playwright integration?

Thanks

juan-fernandez commented 1 year ago

hi @declancarrollcb ! Thanks for the report. This is a known limitation of the current playwright instrumentation: https://docs.datadoghq.com/continuous_integration/tests/javascript/?tab=playwright#adding-custom-tags-to-tests. Since tests are run in a browser it makes the logic slightly more complicated. It's in our roadmap to add this feature though, so I'll keep you updated.

declancarrollcb commented 1 year ago

Are there any hacky workarounds that I could use in the meantime? My only potential thought would be to add the tags to the test name itself and then create a log parser to extract them out etc.

juan-fernandez commented 1 year ago

Are there any hacky workarounds that I could use in the meantime? My only potential thought would be to add the tags to the test name itself and then create a log parser to extract them out etc.

I can't think of workarounds right now, even hacky ones. Using test names might work but that would ruin the rest of the experience using CI Visibility. We'll keep in mind this issue when prioritizing the task though 😄.

juan-fernandez commented 11 months ago

hey @declancarrollcb !

I finally came up with a way to support custom tags in https://github.com/DataDog/dd-trace-js/pull/3741.

It's indeed using the custom annotations API from playwright, so it should feel more or less natural:

test('user profile', async ({ page }) => {
  test.info().annotations.push({ type: 'DD_TAGS[test.memory.usage]', description: 'low' })
  // ...
});

or in your case:

test.info().annotations().put("DD_TAGS[test.requirement]", "RISK-009");