Skip to content

Commit

Permalink
Merge pull request #1 from juliusmarminge/trpc-11
Browse files Browse the repository at this point in the history
feat: support trpc11
  • Loading branch information
Ankcorn authored Feb 12, 2024
2 parents 99b1b51 + fd995f6 commit 06e2791
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
14 changes: 10 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@
},
"homepage": "https://github.com/baselime/node-opentelemetry#readme",
"peerDependencies": {
"@trpc/server": "^10.0.0"
"@trpc/server": "^10.0.0 || ^11.0.0"
},
"peerDependenciesMeta": {
"@trpc/server": {
"optional": true
}
},
"dependencies": {
"@opentelemetry/api": "^1.7.0",
Expand Down
7 changes: 5 additions & 2 deletions src/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ export function tracing(options?: TracingOptions) {
return tracer.startActiveSpan(`TRPC ${opts.type}`, async (span: Span) => {
const result = await opts.next();

if (options.collectInput && typeof opts.rawInput === "object") {
span.setAttributes(flatten({ input: opts.rawInput }))
// opts.rawInput is for v10, `opts.getRawInput` is for v11
const rawInput =
"rawInput" in opts ? opts.rawInput : await opts.getRawInput();
if (options.collectInput && typeof rawInput === "object") {
span.setAttributes(flatten({ input: rawInput }))
}
const meta = { path: opts.path, type: opts.type, ok: result.ok };
span.setAttributes(meta)
Expand Down

0 comments on commit 06e2791

Please sign in to comment.