-
Notifications
You must be signed in to change notification settings - Fork 22
feat(opentelemetry): create otel instrumentation for typed-express-router #1044
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
base: master
Are you sure you want to change the base?
feat(opentelemetry): create otel instrumentation for typed-express-router #1044
Conversation
7b37e6f
to
9c177cd
Compare
typed-express-router
9c177cd
to
0bff27e
Compare
packages/opentelemetry-instrumentation-typed-express-router/test/instrumentation.test.ts
Outdated
Show resolved
Hide resolved
// Note: We cannot test the actual patching functionality in isolation | ||
// because it requires a real typed-express-router module. | ||
// Integration tests will cover this part. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you help me understand the utility provided by this test file? I see that we are checking whether or not internal values are set, but we aren't extending the assertion to cover the behavior that this modifies in an TypedExpressRouterInstrumentation
instance.
packages/opentelemetry-instrumentation-typed-express-router/test/integration.test.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-instrumentation-typed-express-router/src/version.ts
Outdated
Show resolved
Hide resolved
export function handleValidationErrors(span: Span, errors: Errors): void { | ||
const validationErrors = PathReporter.failure(errors); | ||
const validationErrorMessage = validationErrors.join('\n'); | ||
|
||
span.setStatus({ | ||
code: SpanStatusCode.ERROR, | ||
message: 'Validation error', | ||
}); | ||
|
||
span.setAttribute(ApiTsAttributes.API_TS_VALIDATION_ERROR, validationErrorMessage); | ||
|
||
// Record exception event for better error reporting | ||
span.recordException({ | ||
name: 'ValidationError', | ||
message: validationErrorMessage, | ||
}); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code coverage in this package is at 32% of statements, so I'm not sure we've sufficiently asserted that the instrumentation use cases we expose create the desired spans. This function isn't used anywhere else in this PR. Can you please create a test case for it and other functions exposed to users of this library?
We should include assertions that fix the behavior of this code, namely that this instrumenter creates spans containing the data and format we desire. This prevents future regressions and acts as a form of documentation because users of the library can be the test cases to learn from a known working context how to use this library and what benefit it provides them.
packages/opentelemetry-instrumentation-typed-express-router/test/integration.test.ts
Fixed
Show fixed
Hide fixed
packages/opentelemetry-instrumentation-typed-express-router/test/integration.test.ts
Fixed
Show fixed
Hide fixed
packages/opentelemetry-instrumentation-typed-express-router/test/integration.test.ts
Fixed
Show fixed
Hide fixed
packages/opentelemetry-instrumentation-typed-express-router/test/integration.test.ts
Fixed
Show fixed
Hide fixed
packages/opentelemetry-instrumentation-typed-express-router/test/integration.test.ts
Fixed
Show fixed
Hide fixed
43daf20
to
3781856
Compare
Ticket: DX-1473
This PR implements an opentelemetry instrumentation for @api-ts/typed-express-router.
It patches the library's
wrapRouter
andcreateRouter
functions and adds middleware to each request method.To use this instrumentation, register it with the otel sdk.