Skip to content

Commit

Permalink
auth goodies
Browse files Browse the repository at this point in the history
  • Loading branch information
Micha 'mies' Hernandez van Leuffen committed Dec 18, 2024
1 parent 1e6ced8 commit 6a0e375
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
1 change: 1 addition & 0 deletions fpx-workers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ tracing-web = { version = "0.1", default-features = false }
worker = { version = "0.3", features = ["http", "axum", "d1"] }
worker-macros = { version = "0.3", features = ["http"] }
wasm-bindgen = { version = "0.2", default-features = false }

9 changes: 9 additions & 0 deletions fpx-workers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ Now you can simply run the worker using the wrangler CLI:
npx wrangler dev
```

Testing the authenticated `/v1/traces` endpoint:

```bash
curl -X POST http://localhost:8787/v1/traces \
-H "Authorization: Bearer your-secret-token-here" \
-H "Content-Type: application/json" \
--data-binary @trace.json
```

The Rust code will be compiled and once that is finished a local server will be
running on `http://localhost:8787`. You can send traces using any otel exporter
and inspect the traces using the [`fpx client`](../fpx).
Expand Down
86 changes: 86 additions & 0 deletions fpx-workers/trace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"resourceSpans": [
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": { "stringValue": "test-service" }
},
{
"key": "service.version",
"value": { "stringValue": "1.0.0" }
},
{
"key": "deployment.environment",
"value": { "stringValue": "production" }
}
]
},
"scopeSpans": [
{
"scope": {
"name": "test-instrumentation",
"version": "1.0.0"
},
"spans": [
{
"traceId": "7bba9f33312b3dbb8b2c2c62bb7abe2d",
"spanId": "086e83747d0e381e",
"parentSpanId": "",
"name": "GET /api/users",
"kind": 2,
"startTimeUnixNano": "1648138140000000000",
"endTimeUnixNano": "1648138141000000000",
"attributes": [
{
"key": "http.method",
"value": { "stringValue": "GET" }
},
{
"key": "http.url",
"value": { "stringValue": "/api/users" }
},
{
"key": "http.status_code",
"value": { "intValue": "200" }
}
],
"status": {
"code": 1,
"message": "success"
}
},
{
"traceId": "7bba9f33312b3dbb8b2c2c62bb7abe2d",
"spanId": "1f2d33cabb1e1234",
"parentSpanId": "086e83747d0e381e",
"name": "database.query",
"kind": 3,
"startTimeUnixNano": "1648138140200000000",
"endTimeUnixNano": "1648138140800000000",
"attributes": [
{
"key": "db.system",
"value": { "stringValue": "postgresql" }
},
{
"key": "db.statement",
"value": { "stringValue": "SELECT * FROM users" }
},
{
"key": "db.rows_affected",
"value": { "intValue": "42" }
}
],
"status": {
"code": 1,
"message": "success"
}
}
]
}
]
}
]
}
3 changes: 3 additions & 0 deletions fpx-workers/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ watch_dir = [
[[migrations]]
tag = "v1"
new_classes = ["WebSocketHibernationServer"]

[vars]
API_TOKEN = "your-secret-token-here"

0 comments on commit 6a0e375

Please sign in to comment.