@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";
2
+ export { registerInstrumentations } from "@opentelemetry/instrumentation";
3
+ export { type RegisterParams, register } from "./register";
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/src/index.js CHANGED
@@ -1,21 +1,10 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.trace = void 0;
3
+ exports.register = exports.registerInstrumentations = exports.trace = void 0;
18
4
  var api_1 = require("@opentelemetry/api");
19
5
  Object.defineProperty(exports, "trace", { enumerable: true, get: function () { return api_1.trace; } });
20
- __exportStar(require("./register"), exports);
6
+ var instrumentation_1 = require("@opentelemetry/instrumentation");
7
+ Object.defineProperty(exports, "registerInstrumentations", { enumerable: true, get: function () { return instrumentation_1.registerInstrumentations; } });
8
+ var register_1 = require("./register");
9
+ Object.defineProperty(exports, "register", { enumerable: true, get: function () { return register_1.register; } });
21
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAA2C;AAAlC,4FAAA,KAAK,OAAA;AACd,6CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,0CAA2C;AAAlC,4FAAA,KAAK,OAAA;AACd,kEAA0E;AAAjE,2HAAA,wBAAwB,OAAA;AACjC,uCAA2D;AAA7B,oGAAA,QAAQ,OAAA"}
@@ -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"}
@@ -8,7 +8,32 @@ const exporter_trace_otlp_proto_1 = require("@opentelemetry/exporter-trace-otlp-
8
8
  const resources_1 = require("@opentelemetry/resources");
9
9
  const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
10
10
  const config_1 = require("./config");
11
- function register({ url: paramsUrl, apiKey: paramsApiKey, projectName = "default", batch = true, setGlobalTracerProvider = true, }) {
11
+ const instrumentation_1 = require("@opentelemetry/instrumentation");
12
+ /**
13
+ * Registers Phoenix OpenTelemetry tracing with the specified configuration
14
+ *
15
+ * @param params - Configuration parameters for Phoenix tracing
16
+ * @param params.url - The URL to the phoenix server. Can be postfixed with tracing path
17
+ * @param params.apiKey - The API key for the phoenix instance
18
+ * @param params.projectName - The project the spans should be associated to
19
+ * @param params.instrumentations - A list of instrumentation to register
20
+ * @param params.batch - Whether to use batching for span processing
21
+ * @param params.global - Whether to set the tracer as a global provider
22
+ * @returns {NodeTracerProvider} The configured NodeTracerProvider instance
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * import { register } from '@arizeai/phoenix-otel';
27
+ *
28
+ * const provider = register({
29
+ * projectName: 'my-app',
30
+ * url: 'https://app.phoenix.arize.com',
31
+ * apiKey: 'your-api-key',
32
+ * batch: true
33
+ * });
34
+ * ```
35
+ */
36
+ function register({ url: paramsUrl, apiKey: paramsApiKey, projectName = "default", instrumentations, batch = true, global = true, }) {
12
37
  const url = ensureCollectorEndpoint(paramsUrl || (0, config_1.getEnvCollectorURL)() || "http://localhost:6006");
13
38
  const apiKey = paramsApiKey || (0, config_1.getEnvApiKey)();
14
39
  const headers = {};
@@ -33,15 +58,23 @@ function register({ url: paramsUrl, apiKey: paramsApiKey, projectName = "default
33
58
  }),
34
59
  spanProcessors: [spanProcessor],
35
60
  });
36
- if (setGlobalTracerProvider) {
61
+ if (instrumentations) {
62
+ (0, instrumentation_1.registerInstrumentations)({
63
+ instrumentations,
64
+ tracerProvider: provider,
65
+ });
66
+ }
67
+ if (global) {
37
68
  provider.register();
38
69
  }
39
70
  return provider;
40
71
  }
41
72
  /**
42
- * A utility method to normalize the url to be http compatible.
43
- * Assumes we are using http over gRPC.
44
- * @param url the url to the phoenix server. May contain a slug
73
+ * A utility method to normalize the URL to be HTTP compatible.
74
+ * Assumes we are using HTTP over gRPC and ensures the URL ends with the correct traces endpoint.
75
+ *
76
+ * @param url - The URL to the phoenix server. May contain a slug
77
+ * @returns {string} The normalized URL with the '/v1/traces' endpoint
45
78
  */
46
79
  function ensureCollectorEndpoint(url) {
47
80
  if (!url.includes("/v1/traces")) {
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/register.ts"],"names":[],"mappings":";;AA2CA,4BAqCC;AAOD,0DAKC;AA5FD,oGAAuF;AACvF,wEAGuC;AACvC,wFAA6E;AAC7E,wDAAkE;AAClE,kEAGuC;AACvC,qCAA4D;AAgC5D,SAAgB,QAAQ,CAAC,EACvB,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,YAAY,EACpB,WAAW,GAAG,SAAS,EACvB,KAAK,GAAG,IAAI,EACZ,uBAAuB,GAAG,IAAI,GACf;IACf,MAAM,GAAG,GAAG,uBAAuB,CACjC,SAAS,IAAI,IAAA,2BAAkB,GAAE,IAAI,uBAAuB,CAC7D,CAAC;IACF,MAAM,MAAM,GAAG,YAAY,IAAI,IAAA,qBAAY,GAAE,CAAC;IAC9C,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,gBAAgB,GAAG,OAAO,MAAM,IAAI,QAAQ,CAAC;IACnD,IAAI,gBAAgB,EAAE,CAAC;QACrB,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,MAAM,EAAE,CAAC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