Skip to content

Commit

Permalink
chore(http-instrumentation): split up the regex to make it more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
marcbachmann committed Jan 18, 2021
1 parent e6a05de commit 83bb84b
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ export const TRACE_PARENT_HEADER = 'traceparent';
export const TRACE_STATE_HEADER = 'tracestate';

const VERSION = '00';
const TRACE_PARENT_REGEX = /^\s?((?!ff)[\da-f]{2})-((?![0]{32})[\da-f]{32})-((?![0]{16})[\da-f]{16})-([\da-f]{2})(-.*)?\s?$/;
const VERSION_REGEX = /(?!ff)[\da-f]{2}/;
const TRACE_ID_REGEX = /(?![0]{32})[\da-f]{32}/;
const PARENT_ID_REGEX = /(?![0]{16})[\da-f]{16}/;
const FLAGS_REGEX = /[\da-f]{2}/;
const TRACE_PARENT_REGEX = new RegExp(
`^\\s?(${VERSION_REGEX.source})-(${TRACE_ID_REGEX.source})-(${PARENT_ID_REGEX.source})-(${FLAGS_REGEX.source})(-.*)?\\s?$`
);

/**
* Parses information from the [traceparent] span tag and converts it into {@link SpanContext}
Expand Down

0 comments on commit 83bb84b

Please sign in to comment.