0.1.13 • Published 9 months ago

@jahands/otel-cf-workers v0.1.13

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@jahands/otel-cf-workers

A bundled version of @microlabs/otel-cf-workers to work around issues with @cloudflare/vitest-pool-workers

IMPORTANT

Please note that this is primarily intended for my own use. You may want to copy this package to your own repo rather than depending on this library directly.

Usage

Install

# Install using your favorite package manager:
npm install @jahands/otel-cf-workers
pnpm add @jahands/otel-cf-workers
bun add @jahands/otel-cf-workers
yarn add @jahands/otel-cf-workers

Example

import { instrument, ResolveConfigFn, trace } from '@jahands/otel-cf-workers'

export interface Env {
	HONEYCOMB_API_KEY: string
	OTEL_TEST: KVNamespace
}

const handler = {
	async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
		await fetch('https://cloudflare.com')

		const greeting = "G'day World"
		trace.getActiveSpan()?.setAttribute('greeting', greeting)
		ctx.waitUntil(fetch('https://workers.dev'))
		return new Response(`${greeting}!`)
	},
}

const config: ResolveConfigFn = (env: Env, _trigger) => {
	return {
		exporter: {
			url: 'https://api.honeycomb.io/v1/traces',
			headers: { 'x-honeycomb-team': env.HONEYCOMB_API_KEY },
		},
		service: { name: 'greetings' },
	}
}

export default instrument(handler, config)

For more details, refer to documentation in @microlabs/otel-cf-workers

0.1.13

9 months ago

0.1.12

9 months ago

0.1.11

9 months ago

0.1.10

9 months ago

0.1.9

9 months ago

0.1.8

9 months ago

0.1.7

10 months ago

0.1.6

10 months ago

0.1.5

10 months ago

0.1.4

10 months ago

0.1.3

10 months ago