@pydantic/logfire-cf-workers 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o="https://logfire-api.pydantic.dev/";function i({baseUrl:t=o,token:r}){return t.endsWith("/")||(t+="/"),{headers:{Authorization:r},url:`${t}v1/traces`}}function n(t){for(const r of t)for(const e of Object.keys(r.attributes))(r.attributes[e]===void 0||r.attributes[e]===null)&&delete r.attributes[e];return t}function u(t){const{LOGFIRE_BASE_URL:r=o,LOGFIRE_TOKEN:e}=t;return{exporter:i({baseUrl:r,token:e}),postProcessor:n}}exports.cloudflareExporterConfig=i;exports.filterEmptyAttributes=n;exports.tracerConfig=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@microlabs/otel-cf-workers"),o=require("@pydantic/logfire-api"),a="https://logfire-api.pydantic.dev/";function c(e){const s=new o.LogfireAttributeScrubber;return t=>{let{LOGFIRE_BASE_URL:r=a,LOGFIRE_TOKEN:i}=t;return r.endsWith("/")||(r+="/"),{exporter:{headers:{Authorization:i},url:`${r}v1/traces`},postProcessor:n=>l(n,s),service:{name:e.serviceName??"cloudflare-worker",namespace:e.serviceNamespace??"",version:e.serviceVersion??"0.0.0"}}}}function b(e,s){return u.instrument(e,c(s))}function l(e,s){for(const t of e){for(const r of Object.keys(t.attributes)){const i=t.attributes[r];i==null&&delete t.attributes[r]}Object.assign(t.attributes,o.serializeAttributes(t.attributes,s))}return e}exports.instrument=b;
package/dist/index.d.cts CHANGED
@@ -1,22 +1,14 @@
1
- import { OTLPExporterConfig } from '@microlabs/otel-cf-workers';
2
- import { PostProcessorFn } from '@microlabs/otel-cf-workers';
3
- import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
4
-
5
1
  export declare interface CloudflareConfigOptions {
6
2
  baseUrl?: string;
7
3
  token: string;
8
4
  }
9
5
 
10
- export declare function cloudflareExporterConfig({ baseUrl, token }: CloudflareConfigOptions): OTLPExporterConfig;
11
-
12
- export declare function filterEmptyAttributes(spans: ReadableSpan[]): ReadableSpan[];
6
+ export declare function instrument<T>(handler: T, config: LogfireCloudflareConfigOptions): T;
13
7
 
14
- export declare function tracerConfig(env: {
15
- LOGFIRE_BASE_URL?: string;
16
- LOGFIRE_TOKEN: string;
17
- }): {
18
- exporter: OTLPExporterConfig;
19
- postProcessor: PostProcessorFn;
20
- };
8
+ export declare interface LogfireCloudflareConfigOptions {
9
+ serviceName?: string;
10
+ serviceNamespace?: string;
11
+ serviceVersion?: string;
12
+ }
21
13
 
22
14
  export { }
package/dist/index.d.ts CHANGED
@@ -1,22 +1,14 @@
1
- import { OTLPExporterConfig } from '@microlabs/otel-cf-workers';
2
- import { PostProcessorFn } from '@microlabs/otel-cf-workers';
3
- import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
4
-
5
1
  export declare interface CloudflareConfigOptions {
6
2
  baseUrl?: string;
7
3
  token: string;
8
4
  }
9
5
 
10
- export declare function cloudflareExporterConfig({ baseUrl, token }: CloudflareConfigOptions): OTLPExporterConfig;
11
-
12
- export declare function filterEmptyAttributes(spans: ReadableSpan[]): ReadableSpan[];
6
+ export declare function instrument<T>(handler: T, config: LogfireCloudflareConfigOptions): T;
13
7
 
14
- export declare function tracerConfig(env: {
15
- LOGFIRE_BASE_URL?: string;
16
- LOGFIRE_TOKEN: string;
17
- }): {
18
- exporter: OTLPExporterConfig;
19
- postProcessor: PostProcessorFn;
20
- };
8
+ export declare interface LogfireCloudflareConfigOptions {
9
+ serviceName?: string;
10
+ serviceNamespace?: string;
11
+ serviceVersion?: string;
12
+ }
21
13
 
22
14
  export { }
package/dist/index.js CHANGED
@@ -1,25 +1,37 @@
1
- const o = "https://logfire-api.pydantic.dev/";
2
- function n({ baseUrl: t = o, token: r }) {
3
- return t.endsWith("/") || (t += "/"), {
4
- headers: { Authorization: r },
5
- url: `${t}v1/traces`
1
+ import { instrument as n } from "@microlabs/otel-cf-workers";
2
+ import { LogfireAttributeScrubber as a, serializeAttributes as u } from "@pydantic/logfire-api";
3
+ const c = "https://logfire-api.pydantic.dev/";
4
+ function b(t) {
5
+ const s = new a();
6
+ return (e) => {
7
+ let { LOGFIRE_BASE_URL: r = c, LOGFIRE_TOKEN: i } = e;
8
+ return r.endsWith("/") || (r += "/"), {
9
+ exporter: {
10
+ headers: { Authorization: i },
11
+ url: `${r}v1/traces`
12
+ },
13
+ postProcessor: (o) => f(o, s),
14
+ service: {
15
+ name: t.serviceName ?? "cloudflare-worker",
16
+ namespace: t.serviceNamespace ?? "",
17
+ version: t.serviceVersion ?? "0.0.0"
18
+ }
19
+ };
6
20
  };
7
21
  }
8
- function i(t) {
9
- for (const r of t)
10
- for (const e of Object.keys(r.attributes))
11
- (r.attributes[e] === void 0 || r.attributes[e] === null) && delete r.attributes[e];
12
- return t;
22
+ function p(t, s) {
23
+ return n(t, b(s));
13
24
  }
14
- function a(t) {
15
- const { LOGFIRE_BASE_URL: r = o, LOGFIRE_TOKEN: e } = t;
16
- return {
17
- exporter: n({ baseUrl: r, token: e }),
18
- postProcessor: i
19
- };
25
+ function f(t, s) {
26
+ for (const e of t) {
27
+ for (const r of Object.keys(e.attributes)) {
28
+ const i = e.attributes[r];
29
+ i == null && delete e.attributes[r];
30
+ }
31
+ Object.assign(e.attributes, u(e.attributes, s));
32
+ }
33
+ return t;
20
34
  }
21
35
  export {
22
- n as cloudflareExporterConfig,
23
- i as filterEmptyAttributes,
24
- a as tracerConfig
36
+ p as instrument
25
37
  };
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "stats",
23
23
  "monitoring"
24
24
  ],
25
- "version": "0.2.1",
25
+ "version": "0.3.0",
26
26
  "type": "module",
27
27
  "main": "./dist/index.cjs",
28
28
  "module": "./dist/index.js",
@@ -48,9 +48,12 @@
48
48
  "prepack": "cp ../../LICENSE .",
49
49
  "postpack": "rm LICENSE"
50
50
  },
51
+ "dependencies": {
52
+ "@pydantic/logfire-api": "*",
53
+ "@microlabs/otel-cf-workers": "^1.0.0-rc.49"
54
+ },
51
55
  "devDependencies": {
52
- "@microlabs/otel-cf-workers": "^1.0.0-rc.49",
53
- "@opentelemetry/exporter-trace-otlp-proto": "^0.57.2",
56
+ "@cloudflare/workers-types": "4.20250311.0",
54
57
  "@opentelemetry/sdk-trace-base": "^1.30.1",
55
58
  "@pydantic/logfire-tooling-config": "*",
56
59
  "eslint": "^9.22.0",
@@ -60,11 +63,6 @@
60
63
  "vite-plugin-dts": "^4.5.3",
61
64
  "vitest": "^3.0.8"
62
65
  },
63
- "peerDependencies": {
64
- "@microlabs/otel-cf-workers": "^1.0.0-rc.49",
65
- "@opentelemetry/exporter-trace-otlp-proto": "^0.57.2",
66
- "@opentelemetry/sdk-trace-base": "^1.30.1"
67
- },
68
66
  "files": [
69
67
  "dist",
70
68
  "LICENSE"