-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: CXSPA-2067 SSR Logging - Trace Context (#17597)
Introducing the Trace Context extension, a significant advancement in server-side rendering (SSR) logging. This feature elevates contextual logging by seamlessly incorporating Trace Context parameters into SSR logs. For detailed information on Trace Context, please refer to the official documentation at https://www.w3.org/TR/trace-context/#overview. With this pull request, we are now bridging the power of Trace Context to your SSR logs. Our utilities seamlessly map headers to trace context parameters, enabling you to effortlessly expand the context of your SSR logs. This enhancement opens up new possibilities, allowing you to effortlessly connect logs from popular monitoring tools like Kibana to distributed trace presentation tools like Dynatrace. Closes CXSPA-2067
- Loading branch information
Showing
15 changed files
with
529 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...etup/ssr/logger/loggers/w3c-trace-context/errors/invalid-traceparent-format-error.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { InvalidTraceparentFormatError } from './invalid-traceparent-format-error'; | ||
|
||
describe('InvalidTraceparentFormatError', () => { | ||
it('should be an instance of InstantiationError', () => { | ||
const error = new InvalidTraceparentFormatError(); | ||
expect(error).toBeInstanceOf(InvalidTraceparentFormatError); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
...ibs/setup/ssr/logger/loggers/w3c-trace-context/errors/invalid-traceparent-format-error.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/** | ||
* Error thrown when the traceparent header has an invalid format. | ||
*/ | ||
export class InvalidTraceparentFormatError extends Error { | ||
constructor() { | ||
super('Traceparent header has invalid format.'); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...etup/ssr/logger/loggers/w3c-trace-context/errors/invalid-traceparent-length-error.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { InvalidTraceparentLengthError } from './invalid-traceparent-length-error'; | ||
|
||
describe('InvalidTraceparentFormatError', () => { | ||
it('should be an instance of InstantiationError', () => { | ||
const error = new InvalidTraceparentLengthError(0); | ||
expect(error).toBeInstanceOf(InvalidTraceparentLengthError); | ||
}); | ||
|
||
it('should have the correct message', () => { | ||
const error = new InvalidTraceparentLengthError(20); | ||
expect(error.message).toBe( | ||
`Traceparent header has invalid length: ${20}. Expected 55 characters.` | ||
); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
...ibs/setup/ssr/logger/loggers/w3c-trace-context/errors/invalid-traceparent-length-error.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/** | ||
* Error thrown when the traceparent header has an invalid length. | ||
* @param traceparentLength The length of the traceparent header. | ||
*/ | ||
export class InvalidTraceparentLengthError extends Error { | ||
constructor(traceparentLength: number) { | ||
super( | ||
`Traceparent header has invalid length: ${traceparentLength}. Expected 55 characters.` | ||
); | ||
} | ||
} |
Oops, something went wrong.