-
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: beta
Are you sure you want to change the base?
feat(opentelemetry): create otel instrumentation for typed-express-router #1044
Conversation
9c177cd
to
0bff27e
Compare
packages/opentelemetry-instrumentation-typed-express-router/test/instrumentation.test.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-instrumentation-typed-express-router/test/instrumentation.test.ts
Outdated
Show resolved
Hide resolved
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
packages/opentelemetry-instrumentation-typed-express-router/src/utils.ts
Outdated
Show resolved
Hide resolved
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
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-express/src/terinstrumentation.ts
Fixed
Show fixed
Hide fixed
packages/opentelemetry-instrumentation-express/src/terinstrumentation.ts
Fixed
Show fixed
Hide fixed
packages/opentelemetry-instrumentation-express/src/terinstrumentation.ts
Fixed
Show fixed
Hide fixed
packages/opentelemetry-instrumentation-express/src/terinstrumentation.ts
Fixed
Show fixed
Hide fixed
packages/opentelemetry-instrumentation-express/src/terinstrumentation.ts
Fixed
Show fixed
Hide fixed
packages/opentelemetry-instrumentation-express/src/terinstrumentation.ts
Fixed
Show fixed
Hide fixed
packages/opentelemetry-instrumentation-express/src/terinstrumentation.ts
Fixed
Show fixed
Hide fixed
packages/opentelemetry-instrumentation-express/src/terinstrumentation.ts
Fixed
Show fixed
Hide fixed
packages/opentelemetry-instrumentation-express/test/fixtures/use-express.mjs
Fixed
Show fixed
Hide fixed
packages/opentelemetry-instrumentation-typed-express-router/src/instrumentation.ts
Fixed
Show fixed
Hide fixed
6cd264b
to
11fc7f0
Compare
@@ -20,6 +29,8 @@ import { | |||
WrappedRouterOptions, | |||
} from './types'; | |||
|
|||
import type { Span } from '@opentelemetry/api'; |
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.
Not sure if this is allowed. What happens when @opentelemetry/api isn't installed?
} | ||
}; | ||
next(); | ||
}; | ||
|
||
const endDecodeSpanMiddleware: UncheckedRequestHandler = (req, _, next) => { |
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.
This middleware ends the decode span.
My only concern with this is that we're adding middleware to "check" (mainly just record, we don't throw/send any error status codes) for validation errors even though makeAddUncheckedRoute
implies that the validation shouldn't be checked.
import type { Attributes, Span, Tracer } from '@opentelemetry/api'; | ||
import * as PathReporter from 'io-ts/lib/PathReporter'; | ||
|
||
let otelApi: any; |
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.
Are we able to give this a concrete type definition? I wasn't able to figure out a way
|
||
import { Errors } from 'io-ts'; | ||
import type { SpanMetadata } from './types'; | ||
import type { Attributes, Span, Tracer } from '@opentelemetry/api'; |
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.
Same concern here as the type imports in index.ts
if (require.cache[resolvedPath]) { | ||
require.cache[resolvedPath] = { | ||
...require.cache[resolvedPath], | ||
exports: undefined, | ||
}; | ||
} | ||
delete require.cache[require.resolve('../src/telemetry')]; |
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.
Hack to pretend that package is not available
typed-express-router
f804fb4
to
0158ca3
Compare
Back to you, @starfy84! Co-authored-by: Dereck Tu <[email protected]>
Ticket: DX-1473
This PR implements a manual opentelemetry instrumentation for @api-ts/typed-express-router.
It modifies the library's
wrapRouter
andcreateRouter
functions to create encode and decode spans.For the telemetry to work, @opentelemetry/api needs to be installed