Skip to content

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

Draft
wants to merge 5 commits into
base: beta
Choose a base branch
from

Conversation

starfy84
Copy link
Contributor

@starfy84 starfy84 commented Jun 25, 2025

Ticket: DX-1473

This PR implements a manual opentelemetry instrumentation for @api-ts/typed-express-router.

It modifies the library's wrapRouter and createRouter functions to create encode and decode spans.

For the telemetry to work, @opentelemetry/api needs to be installed

@starfy84 starfy84 self-assigned this Jun 25, 2025
@starfy84 starfy84 force-pushed the DX-1473-create-otel-wrapper-for-typed-express-router branch 2 times, most recently from 9c177cd to 0bff27e Compare June 26, 2025 15:07
@starfy84 starfy84 marked this pull request as ready for review June 26, 2025 15:15
@starfy84 starfy84 requested a review from a team as a code owner June 26, 2025 15:15
@starfy84 starfy84 force-pushed the DX-1473-create-otel-wrapper-for-typed-express-router branch from 43daf20 to 3781856 Compare June 30, 2025 15:38
@ericcrosson-bitgo ericcrosson-bitgo marked this pull request as draft June 30, 2025 20:15
@starfy84 starfy84 force-pushed the DX-1473-create-otel-wrapper-for-typed-express-router branch 4 times, most recently from 6cd264b to 11fc7f0 Compare July 9, 2025 16:24
@starfy84 starfy84 force-pushed the DX-1473-create-otel-wrapper-for-typed-express-router branch from f804fb4 to 0158ca3 Compare July 9, 2025 16:28
@starfy84 starfy84 marked this pull request as ready for review July 9, 2025 16:30
@starfy84 starfy84 changed the base branch from master to beta July 9, 2025 19:55
@ericcrosson-bitgo ericcrosson-bitgo marked this pull request as draft July 10, 2025 21:38
@starfy84 starfy84 force-pushed the DX-1473-create-otel-wrapper-for-typed-express-router branch from a224511 to ab8a123 Compare July 15, 2025 15:19
res.writeHead(400, { 'Content-Type': 'application/json' });
res.write(JSON.stringify({ error: validationErrorMessage }));
res.end();
return {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

express-wrapper modified due to onDecodeError return type being changed

Comment on lines 7 to +11
export function defaultOnDecodeError(
errs: Errors,
_req: express.Request,
res: express.Response,
) {
): ReturnType<OnDecodeErrorFn> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can simplify this thing we wrote several hours into our pair programming session last week with:

export const defaultOnDecodeError: OnDecodeErrorFn = (
  errs,
  _req, // Use _req to indicate it's not used if you prefer
  res
) => {
  // ... 
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants