Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back service binding fetch instrumentation #135

Merged
merged 2 commits into from
May 6, 2024
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
5 changes: 5 additions & 0 deletions .changeset/fluffy-wasps-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@microlabs/otel-cf-workers": patch
---

Add back instrumentation of fetch in service bindings
10 changes: 1 addition & 9 deletions src/instrumentation/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ const isDurableObject = (item?: unknown): item is DurableObjectNamespace => {
return !isJSRPC(item) && !!(item as DurableObjectNamespace)?.idFromName
}

const isServiceBinding = (item?: unknown): item is Fetcher => {
const binding = item as Fetcher
return (!isJSRPC(item) && !!binding.connect) || !!binding.fetch || binding.queue || binding.scheduled
}

export const isVersionMetadata = (item?: unknown): item is WorkerVersionMetadata => {
return (
!isJSRPC(item) &&
Expand All @@ -47,16 +42,13 @@ const instrumentEnv = (env: Record<string, unknown>): Record<string, unknown> =>
return item
}
if (isJSRPC(item)) {
// TODO instrument JSRPC and maybe remove serviceBinding?
return item
return instrumentServiceBinding(item, String(prop))
} else if (isKVNamespace(item)) {
return instrumentKV(item, String(prop))
} else if (isQueue(item)) {
return instrumentQueueSender(item, String(prop))
} else if (isDurableObject(item)) {
return instrumentDOBinding(item, String(prop))
} else if (isServiceBinding(item)) {
return instrumentServiceBinding(item, String(prop))
} else if (isVersionMetadata(item)) {
// we do not need to log accesses to the metadata
return item
Expand Down