Skip to content

Commit

Permalink
Add back service binding fetch instrumentation (#135)
Browse files Browse the repository at this point in the history
* Add back service binding fetch instrumentation

* Add changeset
  • Loading branch information
DaniFoldi committed May 6, 2024
1 parent 3bdda1e commit 0fdf245
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
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

0 comments on commit 0fdf245

Please sign in to comment.