Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion apps/ai-gateway/.dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ CLOUDFLARE_CLIENT_ID=
CLOUDFLARE_CLIENT_SECRET=
DEV_DISABLE_OAUTH=
DEV_CLOUDFLARE_API_TOKEN=
DEV_CLOUDFLARE_EMAIL=

6 changes: 5 additions & 1 deletion apps/ai-gateway/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"durable_objects": {
"bindings": [
Expand Down
1 change: 0 additions & 1 deletion apps/auditlogs/.dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ CLOUDFLARE_CLIENT_ID=
CLOUDFLARE_CLIENT_SECRET=
DEV_DISABLE_OAUTH=
DEV_CLOUDFLARE_API_TOKEN=
DEV_CLOUDFLARE_EMAIL=
6 changes: 5 additions & 1 deletion apps/auditlogs/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"durable_objects": {
"bindings": [
Expand Down
2 changes: 1 addition & 1 deletion apps/autorag/.dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ CLOUDFLARE_CLIENT_ID=
CLOUDFLARE_CLIENT_SECRET=
DEV_DISABLE_OAUTH=
DEV_CLOUDFLARE_API_TOKEN=
DEV_CLOUDFLARE_EMAIL=

6 changes: 5 additions & 1 deletion apps/autorag/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"durable_objects": {
"bindings": [
Expand Down
2 changes: 1 addition & 1 deletion apps/browser-rendering/.dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ CLOUDFLARE_CLIENT_ID=
CLOUDFLARE_CLIENT_SECRET=
DEV_DISABLE_OAUTH=
DEV_CLOUDFLARE_API_TOKEN=
DEV_CLOUDFLARE_EMAIL=

6 changes: 5 additions & 1 deletion apps/browser-rendering/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"durable_objects": {
"bindings": [
Expand Down
1 change: 0 additions & 1 deletion apps/cloudflare-one-casb/.dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ CLOUDFLARE_CLIENT_ID=
CLOUDFLARE_CLIENT_SECRET=
DEV_DISABLE_OAUTH=
DEV_CLOUDFLARE_API_TOKEN=
DEV_CLOUDFLARE_EMAIL=
6 changes: 5 additions & 1 deletion apps/cloudflare-one-casb/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"vars": {
"MCP_SERVER_NAME": "PLACEHOLDER",
Expand Down
6 changes: 5 additions & 1 deletion apps/demo-day/wrangler.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"durable_objects": {
"bindings": [
Expand Down
1 change: 0 additions & 1 deletion apps/dex-analysis/.dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ CLOUDFLARE_CLIENT_ID=
CLOUDFLARE_CLIENT_SECRET=
DEV_DISABLE_OAUTH=
DEV_CLOUDFLARE_API_TOKEN=
DEV_CLOUDFLARE_EMAIL=
6 changes: 5 additions & 1 deletion apps/dex-analysis/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"durable_objects": {
"bindings": [
Expand Down
2 changes: 1 addition & 1 deletion apps/dns-analytics/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ If you'd like to iterate and test your MCP server, you can do so in local develo

```
DEV_DISABLE_OAUTH=true
DEV_CLOUDFLARE_EMAIL=your_cloudflare_email
your_cloudflare_email
# This is your api token with endpoint access.
DEV_CLOUDFLARE_API_TOKEN=your_development_api_token
```
Expand Down
6 changes: 5 additions & 1 deletion apps/dns-analytics/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"durable_objects": {
"bindings": [
Expand Down
6 changes: 5 additions & 1 deletion apps/docs-autorag/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"durable_objects": {
"bindings": [
Expand Down
6 changes: 5 additions & 1 deletion apps/docs-vectorize/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"durable_objects": {
"bindings": [
Expand Down
6 changes: 5 additions & 1 deletion apps/graphql/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"durable_objects": {
"bindings": [
Expand Down
1 change: 0 additions & 1 deletion apps/logpush/.dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ CLOUDFLARE_CLIENT_ID=
CLOUDFLARE_CLIENT_SECRET=
DEV_DISABLE_OAUTH=
DEV_CLOUDFLARE_API_TOKEN=
DEV_CLOUDFLARE_EMAIL=
6 changes: 5 additions & 1 deletion apps/logpush/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"durable_objects": {
"bindings": [
Expand Down
2 changes: 1 addition & 1 deletion apps/radar/.dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ CLOUDFLARE_CLIENT_ID=
CLOUDFLARE_CLIENT_SECRET=
DEV_DISABLE_OAUTH=
DEV_CLOUDFLARE_API_TOKEN=
DEV_CLOUDFLARE_EMAIL=

1 change: 0 additions & 1 deletion apps/radar/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ If you'd like to iterate and test your MCP server, you can do so in local develo

```
DEV_DISABLE_OAUTH=true
DEV_CLOUDFLARE_EMAIL=your_cloudflare_email
# This is your global api token
DEV_CLOUDFLARE_API_TOKEN=your_development_api_token
```
Expand Down
6 changes: 5 additions & 1 deletion apps/radar/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"durable_objects": {
"bindings": [
Expand Down
1 change: 0 additions & 1 deletion apps/sandbox-container/.dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ CLOUDFLARE_CLIENT_ID=
CLOUDFLARE_CLIENT_SECRET=
DEV_DISABLE_OAUTH=
DEV_CLOUDFLARE_API_TOKEN=
DEV_CLOUDFLARE_EMAIL=
6 changes: 5 additions & 1 deletion apps/sandbox-container/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"kv_namespaces": [
{
Expand Down
1 change: 0 additions & 1 deletion apps/workers-bindings/.dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ CLOUDFLARE_CLIENT_ID=
CLOUDFLARE_CLIENT_SECRET=
DEV_DISABLE_OAUTH=
DEV_CLOUDFLARE_API_TOKEN=
DEV_CLOUDFLARE_EMAIL=
1 change: 0 additions & 1 deletion apps/workers-bindings/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ If you'd like to iterate and test your MCP server, you can do so in local develo

```
DEV_DISABLE_OAUTH=true
DEV_CLOUDFLARE_EMAIL=your_cloudflare_email
# This is your global api token
DEV_CLOUDFLARE_API_TOKEN=your_development_api_token
```
Expand Down
6 changes: 5 additions & 1 deletion apps/workers-bindings/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"dev": {
"port": 8976
Expand Down
2 changes: 1 addition & 1 deletion apps/workers-builds/.dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ CLOUDFLARE_CLIENT_SECRET=
# OR
DEV_DISABLE_OAUTH=
DEV_CLOUDFLARE_API_TOKEN=
DEV_CLOUDFLARE_EMAIL=

1 change: 0 additions & 1 deletion apps/workers-builds/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ If you'd like to iterate and test your MCP server, you can do so in local develo

```
DEV_DISABLE_OAUTH=true
DEV_CLOUDFLARE_EMAIL=your_cloudflare_email
# This is your global api token
DEV_CLOUDFLARE_API_TOKEN=your_development_api_token
```
Expand Down
6 changes: 5 additions & 1 deletion apps/workers-builds/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"durable_objects": {
"bindings": [
Expand Down
2 changes: 1 addition & 1 deletion apps/workers-observability/.dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ CLOUDFLARE_CLIENT_ID=
CLOUDFLARE_CLIENT_SECRET=
DEV_DISABLE_OAUTH=
DEV_CLOUDFLARE_API_TOKEN=
DEV_CLOUDFLARE_EMAIL=

2 changes: 0 additions & 2 deletions apps/workers-observability/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ If you'd like to iterate and test your MCP server, you can do so in local develo

```
DEV_DISABLE_OAUTH=true
DEV_CLOUDFLARE_EMAIL=your_cloudflare_email
# This is your global api token
DEV_CLOUDFLARE_API_TOKEN=your_development_api_token
```

Expand Down
1 change: 1 addition & 0 deletions apps/workers-observability/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"agents": "0.2.7",
"cloudflare": "4.2.0",
"hono": "4.7.6",
"workers-tagged-logger": "0.13.5",
"zod": "3.24.2"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { writeToString } from '@fast-csv/format'
import { WorkersLogger } from 'workers-tagged-logger'

import {
handleWorkerLogsKeys,
Expand All @@ -14,6 +15,10 @@ import {

import type { ObservabilityMCP } from '../workers-observability.app'

type Tags = {
toolName?: string
}
const logger = new WorkersLogger<Tags>()
/**
* Registers the logs analysis tool with the MCP server
* @param server The MCP server instance
Expand Down Expand Up @@ -49,9 +54,15 @@ This tool provides three primary views of your Worker data:
{
query: zQueryRunRequest,
},
async ({ query }) => {
async ({ query }, req) => {
logger.setTags({ userAgent: req.requestInfo?.headers?.['mcp-protocol-version'] })
logger.setTags({ mcpSessionId: req.requestInfo?.headers?.['mcp-session-id'] })
logger.setTags({ userAgent: req.requestInfo?.headers?.['sec-ch-ua'] })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if you set the same tag key, i.e userAgent multiple times?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine :)

logger.setTags({ toolName: 'query_worker_observability' })
const accountId = await agent.getActiveAccountId()
logger.setTags({ hasAccount: !!accountId })
if (!accountId) {
logger.warn('Ran Workers Observability Tool')
return {
content: [
{
Expand All @@ -63,8 +74,11 @@ This tool provides three primary views of your Worker data:
}
try {
const props = getProps(agent)
logger.setTags({ datasets: query.parameters?.datasets })
logger.setTags({ view: query.view })
const response = await queryWorkersObservability(props.accessToken, accountId, query)

logger.info('Ran Workers Observability Query')
if (query.view === 'calculations') {
let data = ''
for (const calculation of response?.calculations || []) {
Expand Down
6 changes: 5 additions & 1 deletion apps/workers-observability/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
}
],
"observability": {
"enabled": true
"enabled": true,
"traces": {
"enabled": true,
"head_sampling_rate": 0.1
}
},
"durable_objects": {
"bindings": [
Expand Down
Loading