@arizeai/phoenix-otel 0.0.1 → 0.1.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.
@@ -1,3 +1,5 @@
1
1
  export { trace } from "@opentelemetry/api";
2
- export * from "./register.js";
2
+ export { registerInstrumentations } from "@opentelemetry/instrumentation";
3
+ export { type RegisterParams, register } from "./register.js";
4
+ export { type Instrumentation } from "@opentelemetry/instrumentation";
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,KAAK,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gCAAgC,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { trace } from "@opentelemetry/api";
2
- export * from "./register.js";
2
+ export { registerInstrumentations } from "@opentelemetry/instrumentation";
3
+ export { register } from "./register.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAuB,QAAQ,EAAE,MAAM,YAAY,CAAC"}
@@ -1,12 +1,16 @@
1
1
  import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
2
- type RegisterParams = {
2
+ import { Instrumentation } from "@opentelemetry/instrumentation";
3
+ /**
4
+ * Configuration parameters for registering Phoenix OpenTelemetry tracing
5
+ */
6
+ export type RegisterParams = {
3
7
  /**
4
8
  * The project the spans should be associated to
5
9
  * @default "default"
6
10
  */
7
11
  projectName?: string;
8
12
  /**
9
- * the URL to the phoenix server. Can be postfixed with tracing path.
13
+ * The URL to the phoenix server. Can be postfixed with tracing path.
10
14
  * If not provided, environment variables are checked.
11
15
  * @example "https://app.phoenix.arize.com"
12
16
  */
@@ -22,18 +26,48 @@ type RegisterParams = {
22
26
  * @default true
23
27
  */
24
28
  batch?: boolean;
29
+ /**
30
+ * A list of instrumentation to register.
31
+ * Note: this may only work with commonjs projects. ESM projects will require manually applying instrumentation.
32
+ */
33
+ instrumentations?: Instrumentation[];
25
34
  /**
26
35
  * Whether to set the tracer as a global provider.
27
36
  * @default true
28
37
  */
29
- setGlobalTracerProvider?: boolean;
38
+ global?: boolean;
30
39
  };
31
- export declare function register({ url: paramsUrl, apiKey: paramsApiKey, projectName, batch, setGlobalTracerProvider, }: RegisterParams): NodeTracerProvider;
32
40
  /**
33
- * A utility method to normalize the url to be http compatible.
34
- * Assumes we are using http over gRPC.
35
- * @param url the url to the phoenix server. May contain a slug
41
+ * Registers Phoenix OpenTelemetry tracing with the specified configuration
42
+ *
43
+ * @param params - Configuration parameters for Phoenix tracing
44
+ * @param params.url - The URL to the phoenix server. Can be postfixed with tracing path
45
+ * @param params.apiKey - The API key for the phoenix instance
46
+ * @param params.projectName - The project the spans should be associated to
47
+ * @param params.instrumentations - A list of instrumentation to register
48
+ * @param params.batch - Whether to use batching for span processing
49
+ * @param params.global - Whether to set the tracer as a global provider
50
+ * @returns {NodeTracerProvider} The configured NodeTracerProvider instance
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * import { register } from '@arizeai/phoenix-otel';
55
+ *
56
+ * const provider = register({
57
+ * projectName: 'my-app',
58
+ * url: 'https://app.phoenix.arize.com',
59
+ * apiKey: 'your-api-key',
60
+ * batch: true
61
+ * });
62
+ * ```
63
+ */
64
+ export declare function register({ url: paramsUrl, apiKey: paramsApiKey, projectName, instrumentations, batch, global, }: RegisterParams): NodeTracerProvider;
65
+ /**
66
+ * A utility method to normalize the URL to be HTTP compatible.
67
+ * Assumes we are using HTTP over gRPC and ensures the URL ends with the correct traces endpoint.
68
+ *
69
+ * @param url - The URL to the phoenix server. May contain a slug
70
+ * @returns {string} The normalized URL with the '/v1/traces' endpoint
36
71
  */
37
72
  export declare function ensureCollectorEndpoint(url: string): string;
38
- export {};
39
73
  //# sourceMappingURL=register.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/register.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,kBAAkB,EAEnB,MAAM,+BAA+B,CAAC;AAGvC,KAAK,cAAc,GAAG;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,wBAAgB,QAAQ,CAAC,EACvB,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,YAAY,EACpB,WAAuB,EACvB,KAAY,EACZ,uBAA8B,GAC/B,EAAE,cAAc,sBA+BhB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK3D"}
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/register.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,kBAAkB,EAEnB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,eAAe,EAEhB,MAAM,gCAAgC,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,QAAQ,CAAC,EACvB,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,YAAY,EACpB,WAAuB,EACvB,gBAAgB,EAChB,KAAY,EACZ,MAAa,GACd,EAAE,cAAc,GAAG,kBAAkB,CAqCrC;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK3D"}
@@ -4,7 +4,32 @@ import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
4
4
  import { resourceFromAttributes } from "@opentelemetry/resources";
5
5
  import { NodeTracerProvider, } from "@opentelemetry/sdk-trace-node";
6
6
  import { getEnvApiKey, getEnvCollectorURL } from "./config.js";
7
- export function register({ url: paramsUrl, apiKey: paramsApiKey, projectName = "default", batch = true, setGlobalTracerProvider = true, }) {
7
+ import { registerInstrumentations, } from "@opentelemetry/instrumentation";
8
+ /**
9
+ * Registers Phoenix OpenTelemetry tracing with the specified configuration
10
+ *
11
+ * @param params - Configuration parameters for Phoenix tracing
12
+ * @param params.url - The URL to the phoenix server. Can be postfixed with tracing path
13
+ * @param params.apiKey - The API key for the phoenix instance
14
+ * @param params.projectName - The project the spans should be associated to
15
+ * @param params.instrumentations - A list of instrumentation to register
16
+ * @param params.batch - Whether to use batching for span processing
17
+ * @param params.global - Whether to set the tracer as a global provider
18
+ * @returns {NodeTracerProvider} The configured NodeTracerProvider instance
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { register } from '@arizeai/phoenix-otel';
23
+ *
24
+ * const provider = register({
25
+ * projectName: 'my-app',
26
+ * url: 'https://app.phoenix.arize.com',
27
+ * apiKey: 'your-api-key',
28
+ * batch: true
29
+ * });
30
+ * ```
31
+ */
32
+ export function register({ url: paramsUrl, apiKey: paramsApiKey, projectName = "default", instrumentations, batch = true, global = true, }) {
8
33
  const url = ensureCollectorEndpoint(paramsUrl || getEnvCollectorURL() || "http://localhost:6006");
9
34
  const apiKey = paramsApiKey || getEnvApiKey();
10
35
  const headers = {};
@@ -29,15 +54,23 @@ export function register({ url: paramsUrl, apiKey: paramsApiKey, projectName = "
29
54
  }),
30
55
  spanProcessors: [spanProcessor],
31
56
  });
32
- if (setGlobalTracerProvider) {
57
+ if (instrumentations) {
58
+ registerInstrumentations({
59
+ instrumentations,
60
+ tracerProvider: provider,
61
+ });
62
+ }
63
+ if (global) {
33
64
  provider.register();
34
65
  }
35
66
  return provider;
36
67
  }
37
68
  /**
38
- * A utility method to normalize the url to be http compatible.
39
- * Assumes we are using http over gRPC.
40
- * @param url the url to the phoenix server. May contain a slug
69
+ * A utility method to normalize the URL to be HTTP compatible.
70
+ * Assumes we are using HTTP over gRPC and ensures the URL ends with the correct traces endpoint.
71
+ *
72
+ * @param url - The URL to the phoenix server. May contain a slug
73
+ * @returns {string} The normalized URL with the '/v1/traces' endpoint
41
74
  */
42
75
  export function ensureCollectorEndpoint(url) {
43
76
  if (!url.includes("/v1/traces")) {
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;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