Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
927c07e
feat(node): Migrate to `@fastify/otel`
onurtemizkan Feb 28, 2025
fcaac6f
Inline fastify types
onurtemizkan Feb 28, 2025
d03ba3c
Use default `FastifyOtelInstrumentation` export
onurtemizkan Feb 28, 2025
00df200
Update types.
onurtemizkan Feb 28, 2025
b4bd302
Auto-register @fastify/otel plugin when instrumented.
onurtemizkan Feb 28, 2025
c642e1d
Remove version check.
onurtemizkan Feb 28, 2025
4223850
Switch using `diagnostics_channel`
onurtemizkan Mar 1, 2025
db4d37d
Fix formatting.
onurtemizkan Mar 5, 2025
ebaf3d0
Bump `@fastify/otel` to `0.5.0`
onurtemizkan Mar 20, 2025
8022ecd
Add vendor permalinks
onurtemizkan Mar 25, 2025
cf67513
Move fastify into its own folder.
onurtemizkan Mar 25, 2025
d724509
Update e2e tests
onurtemizkan Mar 25, 2025
8ef02f1
Fix formatting
onurtemizkan Mar 25, 2025
50387b0
Deduplicate deps
onurtemizkan Mar 26, 2025
788a6d8
Reset lockfile
onurtemizkan Mar 26, 2025
1f6546d
Use `skipLibCheck` in e2e tests
onurtemizkan Mar 26, 2025
770d01a
Address review comments
onurtemizkan Apr 3, 2025
f2934a9
Bump `@fastify/otel` to `0.5.2`
onurtemizkan Apr 14, 2025
1d6462c
Dedupe deps
onurtemizkan Apr 14, 2025
088070c
Reset lockfile
onurtemizkan Apr 14, 2025
cf6ea09
Add middie spans back to e2e tests
onurtemizkan Apr 15, 2025
f173415
Realign spans between versions
onurtemizkan Apr 18, 2025
cb1e9ca
Bump Fastify 5 versions to `5.3.1`
onurtemizkan Apr 18, 2025
97ea80d
Set `fastify` as external
onurtemizkan Apr 18, 2025
4ef3cd7
Dedupe deps
onurtemizkan Apr 18, 2025
c35fd27
Try when `fastify` is imported as a `type` on `@fastify/otel`
onurtemizkan Apr 18, 2025
5fb9660
Bump `@fastify/otel` to `0.6.0`
onurtemizkan Apr 22, 2025
bf5bbce
Update types of `fastifyOtelInstrumentationInstance`
onurtemizkan Apr 24, 2025
11d2c5d
Update fastify-3 e2e test proxy name
onurtemizkan Apr 24, 2025
053e707
Align e2e tests
onurtemizkan Apr 24, 2025
baf9945
Reformat with new eslint rules
onurtemizkan May 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Align e2e tests
  • Loading branch information
onurtemizkan committed May 1, 2025
commit 053e707697413601fc59dd4c723460765bc1ca18
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ app.get('/test-outgoing-http-external-disallowed', async function (req, res) {
res.send(data);
});

app.post('/test-post', function (req, res) {
res.send({ status: 'ok', body: req.body });
});

app.listen({ port: port });

// A second app so we can test header propagation between external URLs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,40 @@ test('Sends an API route transaction', async ({ baseURL }) => {
origin: 'manual',
});
});

test('Captures request metadata', async ({ baseURL }) => {
const transactionEventPromise = waitForTransaction('node-fastify-4', transactionEvent => {
return (
transactionEvent?.contexts?.trace?.op === 'http.server' && transactionEvent?.transaction === 'POST /test-post'
);
});

const res = await fetch(`${baseURL}/test-post`, {
method: 'POST',
body: JSON.stringify({ foo: 'bar', other: 1 }),
headers: {
'Content-Type': 'application/json',
},
});
const resBody = await res.json();

expect(resBody).toEqual({ status: 'ok', body: { foo: 'bar', other: 1 } });

const transactionEvent = await transactionEventPromise;

expect(transactionEvent.request).toEqual({
cookies: {},
url: expect.stringMatching(/^http:\/\/localhost:(\d+)\/test-post$/),
method: 'POST',
headers: expect.objectContaining({
'user-agent': expect.stringContaining(''),
'content-type': 'application/json',
}),
data: JSON.stringify({
foo: 'bar',
other: 1,
}),
});

expect(transactionEvent.user).toEqual(undefined);
});
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ app.get('/test-outgoing-http-external-disallowed', async function (req, res) {
res.send(data);
});

app.post('/test-post', function (req, res) {
res.send({ status: 'ok', body: req.body });
});

app.listen({ port: port });

// A second app so we can test header propagation between external URLs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,40 @@ test('Sends an API route transaction', async ({ baseURL }) => {
origin: 'manual',
});
});

test('Captures request metadata', async ({ baseURL }) => {
const transactionEventPromise = waitForTransaction('node-fastify-5', transactionEvent => {
return (
transactionEvent?.contexts?.trace?.op === 'http.server' && transactionEvent?.transaction === 'POST /test-post'
);
});

const res = await fetch(`${baseURL}/test-post`, {
method: 'POST',
body: JSON.stringify({ foo: 'bar', other: 1 }),
headers: {
'Content-Type': 'application/json',
},
});
const resBody = await res.json();

expect(resBody).toEqual({ status: 'ok', body: { foo: 'bar', other: 1 } });

const transactionEvent = await transactionEventPromise;

expect(transactionEvent.request).toEqual({
cookies: {},
url: expect.stringMatching(/^http:\/\/localhost:(\d+)\/test-post$/),
method: 'POST',
headers: expect.objectContaining({
'user-agent': expect.stringContaining(''),
'content-type': 'application/json',
}),
data: JSON.stringify({
foo: 'bar',
other: 1,
}),
});

expect(transactionEvent.user).toEqual(undefined);
});