Skip to content

Commit 0a89004

Browse files
committed
Support attribute substitution in span message
1 parent 54d58e6 commit 0a89004

File tree

18 files changed

+795
-174
lines changed

18 files changed

+795
-174
lines changed

examples/cloudflare-worker/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"deploy": "wrangler deploy",
77
"dev": "wrangler dev",
88
"start": "wrangler dev",
9-
"test": "vitest",
109
"cf-typegen": "wrangler types"
1110
},
1211
"devDependencies": {

examples/express/app.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { Express, Response, Request } from 'express'
1+
import type { Express, Request, Response } from "express";
22
import express from "express";
3-
import * as logfire from 'logfire';
3+
import * as logfire from "logfire";
44

55
const PORT: number = parseInt(process.env.EXPRESS_PORT || "8080");
66
const app: Express = express();
@@ -9,29 +9,32 @@ function getRandomNumber(min: number, max: number) {
99
return Math.floor(Math.random() * (max - min) + min);
1010
}
1111

12-
1312
app.get("/rolldice", (req, res) => {
1413
// read the query parameter error
1514
const error = req.query.error;
1615
if (error) {
1716
throw new Error("An error occurred");
1817
}
1918

20-
21-
logfire.startActiveSpan(logfire.Level.Info, "parent-span", {}, {}, async (parentSpan) => {
22-
logfire.info('child span')
23-
parentSpan.end();
24-
});
19+
logfire.span(
20+
"parent-span",
21+
{},
22+
{},
23+
async (parentSpan) => {
24+
logfire.info("child span");
25+
parentSpan.end();
26+
},
27+
);
2528

2629
res.send(getRandomNumber(1, 6).toString());
2730
});
2831

2932
// Report an error to Logfire, using the Express error handler.
3033
app.use((err: Error, _req: Request, res: Response, _next: () => unknown) => {
31-
logfire.reportError(err.message, err)
32-
res.status(500)
33-
res.send('An error occured')
34-
})
34+
logfire.reportError(err.message, err);
35+
res.status(500);
36+
res.send("An error occured");
37+
});
3538

3639
app.listen(PORT, () => {
3740
console.log(`Listening for requests on http://localhost:${PORT}/rolldice`);

package-lock.json

Lines changed: 217 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"dev": "turbo watch dev",
88
"build": "turbo build",
9-
"test": "echo \"Error: no test specified\" && exit 1",
9+
"test": "turbo test",
1010
"release": "turbo build && npx @changesets/cli publish",
1111
"changeset-add": "npx @changesets/cli add",
1212
"ci": "turbo typecheck lint"

packages/logfire-api/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"preview": "vite preview",
4747
"typecheck": "tsc",
4848
"prepack": "cp ../../LICENSE .",
49-
"postpack": "rm LICENSE"
49+
"postpack": "rm LICENSE",
50+
"test": "vitest"
5051
},
5152
"devDependencies": {
5253
"@opentelemetry/api": "^1.9.0",
@@ -56,7 +57,7 @@
5657
"typescript": "^5.8.2",
5758
"vite": "^6.2.0",
5859
"vite-plugin-dts": "^4.5.3",
59-
"vitest": "^3.0.8"
60+
"vitest": "^3.1.1"
6061
},
6162
"peerDependencies": {
6263
"@opentelemetry/api": "^1.9.0"

0 commit comments

Comments
 (0)