Releases: RichiCoder1/opentelemetry-sdk-workers
Open Telemetry SDK for Cloudflare Workers v0.6.2
Patch Changes
-
94ac17e
Thanks @RichiCoder1! - add support for providing propagatorsYou can now providers to the Workers SDK via
config.propagators
. It's recommended to still provide the default WC3 Context and Baggage Providers.For example:
/* Required to patch missing performance API in Cloudflare Workers. */ import "opentelemetry-sdk-workers/performance"; import { WorkersSDK } from "opentelemetry-sdk-workers"; import { CompositePropagator, W3CBaggagePropagator, W3CTraceContextPropagator, } from "@opentelemetry/core"; import { BigBrandPropagator } from "@big-brand/opentelemetry-propagator"; export interface Env { OTLP_ENDPOINT: string; } export default { async fetch( request: Request, env: Env, ctx: ExecutionContext ): Promise<Response> { const sdk = WorkersSDK.fromEnv(request, env, ctx, { propagator: new CompositePropagator({ propagators: [ new BigBrandPropagator(), new W3CTraceContextPropagator(), new W3CBaggagePropagator(), ], }), }); try { sdk.log.info("Test Log!"); const response = await sdk.fetch("https://httpbin.org/headers/"); return sdk.sendResponse(response); } catch (ex) { sdk.captureException(ex); } }, };
[email protected]
Patch Changes
b0b9be6
Thanks @RichiCoder1! - Clarify exporter fetch error
Open Telemetry SDK for Cloudflare Workers v0.6.0
Minor Changes
-
#21
8391689
Thanks @RichiCoder1! - Add support for fetch-based bindings.You can now trace any
fetch
-based bindings like Service Bindings or Durable Objects.
To use this support, you can pass in the Env to the third argument when creating the Workers SDK and access bindings viasdk.env.<BINDING>
.For example, say you have an authentication service bound as
auth
:/* Required to patch missing performance API in Cloudflare Workers. */ import "opentelemetry-sdk-workers/performance"; import { WorkersSDK } from "opentelemetry-sdk-workers"; export interface Env { OTLP_ENDPOINT: string; /*** * Authentication Service */ AUTH: Fetcher /* Type available from @cloudflare/workers-types */; } export default { async fetch( request: Request, env: Env, ctx: ExecutionContext ): Promise<Response> { const sdk = new WorkersSDK(request, ctx, env, { /* This is the service.name */ service: "worker", /* The OTLP/HTTP JSON Endpoint to send traces */ endpoint: env.OTLP_ENDPOINT, }); try { const authResponse = await sdk.env.AUTH.fetch(request); if (!authResponse.ok) { return sdk.sendResponse(authResponse); } const response = await sdk.fetch("https://httpbin.org/headers/"); return sdk.sendResponse(response); } catch (ex) { sdk.captureException(ex); } }, };
Note
When using TypeScript, you must provide the Environment type with bindings inheriting from theFetcher
type in the@cloudflare/worker-types
in order for them to be available onsdk.env
.
Open Telemetry SDK for Cloudflare Workers v0.5.0
This updates dependencies and makes a number of breaking changes for clarity or compatibility reasons. Be sure to review the notes carefully!
It also fleshes out support for using the fromEnv
helper in WorkersSDK to all moving more configuration out of code.
Minor Changes
-
ac2178d
Thanks @RichiCoder1! - flesh out support for env vars for logging and compressionYou can now provide
OTEL_EXPORTER_LOGS_ENABLED=true
to enable the Logs Exporter, andOTEL_EXPORTER_COMPRESSION_ENABLED=false
to disable automatic exporter compression. -
7e10209
Thanks @RichiCoder1! - BREAKING CHANGE: service name is now requiredYou must now provide the service name via the
service
config option or viaenv.OTLP_SERVICE_NAME
if usingfromEnv
. -
#14
ba6864a
Thanks @BraunreutherA! - The gzip compression for the LogExporter is now optional, as some observability platforms won't accept gzipped streams. Compression is activated by default - please set the property "compress" to false in a LogExporter config to deactivate the compression.Closes #10
-
e64b42f
Thanks @RichiCoder1! - BREAKING CHANGED:sdk.log
renamed tosdk.logger
and console.log disabled by defaultThe SDK logger has be renamed from
sdk.log
tosdk.logger
to clarify that it's a provider and not a method itself.In addition, the logger will no longer output to
console.log
by default. If you'd like to re-enable this behavior, providerconsoleLogEnabled: true
to the configuration or setenv.OTEL_EXPORTER_LOGS_CONSOLE_ENABLED=true
if usingfromEnv
.This may change again in the future to provide multiple explicit "sinks".
Closes #15.
-
3fa6a2f
Thanks @RichiCoder1! - Update dependencies -
8c732df
Thanks @RichiCoder1! - BREAKING CHANGE: URL provided to exporters will now be used verbatimNo change is required if you're just using the
endpoint
option in the config.If you're using exporters explicitly (for example Proto exporters or the Log exporters), you now must either either provide the fully qualified endpoint to
url
or pass the base url in asendpoints.default
.For example:
const sdk = new WorkersSDK(request, ctx, { /* This is the service.name */ service: "worker", /* The OTLP/HTTP JSON Endpoint to send traces */ endpoint: env.OTLP_ENDPOINT, logExporter: new OTLPJsonLogExporter({ - url: env.OTLP_ENDPOINT + endpoints: { default: env.OTLP_ENDPOINT } }), });
or
const sdk = new WorkersSDK(request, ctx, { /* This is the service.name */ service: "worker", /* The OTLP/HTTP JSON Endpoint to send traces */ endpoint: env.OTLP_ENDPOINT, logExporter: new OTLPJsonLogExporter({ - // https://api.otelprovider.io/ - url: env.OTLP_ENDPOINT + // https://api.otelprovider.io/v1/logs/ + url: env.OTLP_LOGS_ENDPOINT }), });
Closes #16
Patch Changes
a60240e
Thanks @RichiCoder1! - adapt to diary behavioral changes
Open Telemetry SDK for Cloudflare Workers v0.4.0
This release majorly reorganized how exporters are constructed. If you weren't using an exporter directly, you shouldn't be affected.
It also adds 🪵 Log 🪵 support! It's currently opt in as a number of providers don't implement support for it by default. See logging for more details.
In addition, gzip
support is enabled by default and you can now send traces and logs encoded as protobuf.
Minor Changes
-
10d3aa8
Thanks @RichiCoder1! - Added OTLP/HTTP Protobuf support as an optional exporter -
#8
cd0f07b
Thanks @RichiCoder1! - Reorganized exporters and added exporter base for extensibility.Exporters are now in
exporters/
and implement a Cloudflare fetch-based exporter base. -
#8
cd0f07b
Thanks @RichiCoder1! - Add compression support to outgoing requests
[email protected]
Minor Changes
bbe5dd6
Thanks @RichiCoder1! - Republishing to solve publishing issues.