Skip to content

Commit

Permalink
feat(publish-metrics): add test id to all traces and metrics (#2505)
Browse files Browse the repository at this point in the history
  • Loading branch information
InesNi committed Feb 19, 2024
1 parent e68006e commit 49f4602
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ class OTelMetricsReporter {
meterName: config.meterName || 'Artillery.io_metrics',
includeOnly: config.includeOnly || [],
exclude: config.exclude || [],
attributes: config.attributes || {}
attributes: {
...(config.attributes || {}),
test_id: global.artillery.testRunId
}
};

this.meterProvider = new MeterProvider({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class OTelTraceBase {
kind: SpanKind.CLIENT,
attributes: {
'vu.uuid': userContext.vars.$uuid,
test_id: userContext.vars.$testId,
[SemanticAttributes.PEER_SERVICE]: this.config.serviceName
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class OTelHTTPTraceReporter extends OTelTraceBase {
kind: SpanKind.CLIENT,
attributes: {
'vu.uuid': userContext.vars.$uuid,
test_id: userContext.vars.$testId,
[SemanticAttributes.HTTP_URL]: parsedUrl || url.href,
// We set the port if it is specified, if not we set to a default port based on the protocol
[SemanticAttributes.HTTP_SCHEME]:
Expand Down Expand Up @@ -121,7 +122,10 @@ class OTelHTTPTraceReporter extends OTelTraceBase {
.startSpan(name, {
kind: SpanKind.CLIENT,
startTime: res.timings[value.start],
attributes: { 'vu.uuid': userContext.vars.$uuid }
attributes: {
'vu.uuid': userContext.vars.$uuid,
test_id: userContext.vars.$testId
}
})
.end(res.timings[value.end]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class OTelPlaywrightTraceReporter extends OTelTraceBase {
async (scenarioSpan) => {
scenarioSpan.setAttributes({
'vu.uuid': vuContext.vars.$uuid,
test_id: vuContext.vars.$testId,
...(this.config.attributes || {})
});
this.pendingPlaywrightScenarioSpans++;
Expand Down Expand Up @@ -115,6 +116,7 @@ class OTelPlaywrightTraceReporter extends OTelTraceBase {
);
pageSpan.setAttributes({
'vu.uuid': vuContext.vars.$uuid,
test_id: vuContext.vars.$testId,
...(this.config.attributes || {})
});
lastPageUrl = pageUrl;
Expand Down Expand Up @@ -170,6 +172,7 @@ class OTelPlaywrightTraceReporter extends OTelTraceBase {
try {
span.setAttributes({
'vu.uuid': vuContext.vars.$uuid,
test_id: vuContext.vars.$testId,
...(this.config.attributes || {})
});

Expand Down

0 comments on commit 49f4602

Please sign in to comment.