@powerlines/plugin-open-telemetry 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.
Files changed (50) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +304 -0
  3. package/dist/_virtual/_rolldown/runtime.cjs +1 -0
  4. package/dist/components/index.cjs +1 -0
  5. package/dist/components/index.d.cts +2 -0
  6. package/dist/components/index.d.mts +2 -0
  7. package/dist/components/index.mjs +1 -0
  8. package/dist/components/trace-builtin.cjs +230 -0
  9. package/dist/components/trace-builtin.d.cts +12 -0
  10. package/dist/components/trace-builtin.d.cts.map +1 -0
  11. package/dist/components/trace-builtin.d.mts +12 -0
  12. package/dist/components/trace-builtin.d.mts.map +1 -0
  13. package/dist/components/trace-builtin.mjs +231 -0
  14. package/dist/components/trace-builtin.mjs.map +1 -0
  15. package/dist/helpers/automd-generator.cjs +1 -0
  16. package/dist/helpers/automd-generator.d.cts +14 -0
  17. package/dist/helpers/automd-generator.d.cts.map +1 -0
  18. package/dist/helpers/automd-generator.d.mts +14 -0
  19. package/dist/helpers/automd-generator.d.mts.map +1 -0
  20. package/dist/helpers/automd-generator.mjs +2 -0
  21. package/dist/helpers/automd-generator.mjs.map +1 -0
  22. package/dist/helpers/index.cjs +1 -0
  23. package/dist/helpers/index.d.cts +2 -0
  24. package/dist/helpers/index.d.mts +2 -0
  25. package/dist/helpers/index.mjs +1 -0
  26. package/dist/index.cjs +1 -0
  27. package/dist/index.d.cts +17 -0
  28. package/dist/index.d.cts.map +1 -0
  29. package/dist/index.d.mts +17 -0
  30. package/dist/index.d.mts.map +1 -0
  31. package/dist/index.mjs +2 -0
  32. package/dist/index.mjs.map +1 -0
  33. package/dist/types/env.cjs +0 -0
  34. package/dist/types/env.d.cts +77 -0
  35. package/dist/types/env.d.cts.map +1 -0
  36. package/dist/types/env.d.mts +77 -0
  37. package/dist/types/env.d.mts.map +1 -0
  38. package/dist/types/env.mjs +2 -0
  39. package/dist/types/env.mjs.map +1 -0
  40. package/dist/types/index.cjs +0 -0
  41. package/dist/types/index.d.cts +3 -0
  42. package/dist/types/index.d.mts +3 -0
  43. package/dist/types/index.mjs +1 -0
  44. package/dist/types/plugin.cjs +0 -0
  45. package/dist/types/plugin.d.cts +139 -0
  46. package/dist/types/plugin.d.cts.map +1 -0
  47. package/dist/types/plugin.d.mts +139 -0
  48. package/dist/types/plugin.d.mts.map +1 -0
  49. package/dist/types/plugin.mjs +1 -0
  50. package/package.json +210 -0
@@ -0,0 +1,17 @@
1
+ import { AttributesFromHeaderFunc, AttributesFromHeaders, Configuration, FetchInstrumentationConfig, InstrumentationConfiguration, InstrumentationOptionOrName, OTLPExporterConfig, OpenTelemetryPluginContext, OpenTelemetryPluginOptions, OpenTelemetryPluginResolvedConfig, OpenTelemetryPluginUserConfig, PropagatorOrName, SampleOrName, SpanExporterOrName, SpanProcessorOrName } from "./types/plugin.mjs";
2
+ import { OpenTelemetryEnv } from "./types/env.mjs";
3
+ import { Plugin } from "powerlines";
4
+
5
+ //#region src/index.d.ts
6
+ declare module "powerlines" {
7
+ interface Config {
8
+ openTelemetry?: OpenTelemetryPluginOptions;
9
+ }
10
+ }
11
+ /**
12
+ * A Powerlines plugin to inject environment variables into the source code.
13
+ */
14
+ declare const plugin: <TContext extends OpenTelemetryPluginContext = OpenTelemetryPluginContext>(options?: OpenTelemetryPluginOptions) => Plugin<TContext>[];
15
+ //#endregion
16
+ export { AttributesFromHeaderFunc, AttributesFromHeaders, Configuration, FetchInstrumentationConfig, InstrumentationConfiguration, InstrumentationOptionOrName, OTLPExporterConfig, OpenTelemetryEnv, OpenTelemetryPluginContext, OpenTelemetryPluginOptions, OpenTelemetryPluginResolvedConfig, OpenTelemetryPluginUserConfig, PropagatorOrName, SampleOrName, SpanExporterOrName, SpanProcessorOrName, plugin as default, plugin };
17
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;YAiCY,MAAA;IACR,aAAA,GAAgB,0BAAA;EAAA;AAAA;;;;cAOP,MAAA,oBACM,0BAAA,GAA6B,0BAAA,EAE9C,OAAA,GAAS,0BAAA,KA2BJ,MAAA,CAAO,QAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import{trace as e}from"./helpers/automd-generator.mjs";import{TraceBuiltin as t}from"./components/trace-builtin.mjs";import{createComponent as n}from"@alloy-js/core/jsx-runtime";import r from"defu";import{render as i}from"@powerlines/plugin-alloy/render";import a from"@powerlines/plugin-automd";import o from"@powerlines/plugin-env";const s=(s={})=>[o(s.env),{name:`open-telemetry`,async prepare(){return this.debug(`Preparing the OpenTelemetry runtime artifacts for the Powerlines project.`),i(this,n(t,{}))}},{name:`open-telemetry:automd-generator`,config(){return{automd:r(s.automd??{},{generators:{trace:e(this)}})}}},a(s.automd)];export{s as default,s as plugin};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport env from \"@powerlines/plugin-env\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { TraceBuiltin } from \"./components/trace-builtin\";\nimport { trace } from \"./helpers/automd-generator\";\nimport type {\n OpenTelemetryPluginContext,\n OpenTelemetryPluginOptions\n} from \"./types/plugin\";\n\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n openTelemetry?: OpenTelemetryPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to inject environment variables into the source code.\n */\nexport const plugin = <\n TContext extends OpenTelemetryPluginContext = OpenTelemetryPluginContext\n>(\n options: OpenTelemetryPluginOptions = {}\n) => {\n return [\n env(options.env),\n {\n name: \"open-telemetry\",\n async prepare() {\n this.debug(\n `Preparing the OpenTelemetry runtime artifacts for the Powerlines project.`\n );\n\n return render(this, <TraceBuiltin />);\n }\n },\n {\n name: \"open-telemetry:automd-generator\",\n config() {\n return {\n automd: defu(options.automd ?? {}, {\n generators: {\n trace: trace(this)\n }\n })\n };\n }\n },\n automd(options.automd)\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":"8VA8BO,CAAA,EAAO,EAAQ,IAAA,CAAM,uBAE5B,MAAQ,SAAQ,CAEZ,OADF,KAAS,MAAC,4EAAO,CACf,EAAgB,KAAA,EAAA,EAA0B,EAAA,CAAA,CAAA,EAE9C,CAAA,wCAEE,QAAA,CACG,MAAA,CACH,OAAA,EAAA,EAAA,QAAA,EAAA,CAAA,CACK,WAAe,CACX,MAAQ,EAAA,KAAA,CAClB,CACQ,CAAC,CACL,EAEF,CAAC,EAAI,EAAY,OAAA,CAAA"}
File without changes
@@ -0,0 +1,77 @@
1
+ import { EnvInterface } from "@powerlines/plugin-env/types/env";
2
+
3
+ //#region src/types/env.d.ts
4
+ /**
5
+ * The base environment configuration used by Powerlines applications
6
+ *
7
+ * @remarks
8
+ * This interface is used to define the environment variables, configuration options, and runtime settings used by applications. It is used to provide type safety, autocompletion, and default values for the environment variables. The comments of each variable are used to provide documentation descriptions when running the \`powerlines docs\` command.
9
+ *
10
+ * @categoryDescription Platform
11
+ * The name of the platform the configuration parameter is intended for use in.
12
+ *
13
+ * @showCategories
14
+ */
15
+ interface OpenTelemetryEnv extends EnvInterface {
16
+ /**
17
+ * The name of the service. If none if provided, the plugin will attempt to use the value of the {@link EnvInterface.APP_NAME} configuration option.
18
+ */
19
+ readonly OTEL_SERVICE_NAME?: string;
20
+ /**
21
+ * The OTLP traces endpoint URL.
22
+ *
23
+ * @defaultValue "http://localhost:4318/v1/traces"
24
+ */
25
+ readonly OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: string;
26
+ /**
27
+ * The supported trace sampler to use.
28
+ *
29
+ * @defaultValue "always_on"
30
+ */
31
+ readonly OTEL_TRACES_SAMPLER: "always_on" | "always_off" | "traceidratio" | "parentbased_traceidratio";
32
+ /**
33
+ * The argument for the trace sampler. For example, if using the "traceidratio" sampler, this would be a number between 0 and 1 representing the sampling ratio.
34
+ *
35
+ * @defaultValue 1
36
+ */
37
+ readonly OTEL_TRACES_SAMPLER_ARG: number;
38
+ /**
39
+ * A comma-separated list of trace exporter types to use. Supported values include "http" and "console".
40
+ *
41
+ * @defaultValue "http"
42
+ */
43
+ readonly OTEL_EXPORTER_TYPES?: string;
44
+ /**
45
+ * A comma-separated list of trace propagator types to use. Supported values include "tracecontext" and "baggage".
46
+ *
47
+ * @defaultValue "tracecontext,baggage"
48
+ */
49
+ readonly OTEL_PROPAGATORS?: string;
50
+ /**
51
+ * A comma-separated list of trace instrumentations to use. Supported values include "http", "express", and "graphql".
52
+ *
53
+ * @defaultValue "http,express"
54
+ */
55
+ readonly OTEL_INSTRUMENTATIONS?: string;
56
+ /**
57
+ * The log level for OpenTelemetry SDK diagnostics. If not set, the {@link EnvInterface.LOG_LEVEL} variable will be used to determine the log level for diagnostics.
58
+ *
59
+ * @defaultValue "INFO"
60
+ */
61
+ readonly OTEL_LOG_LEVEL?: "ALL" | "VERBOSE" | "DEBUG" | "INFO" | "WARN" | "ERROR" | "NONE";
62
+ /**
63
+ * A boolean flag to disable the OpenTelemetry SDK. When set to "true", the plugin will not inject any OpenTelemetry code or configuration into the application.
64
+ *
65
+ * @defaultValue false
66
+ */
67
+ readonly OTEL_SDK_DISABLED: boolean;
68
+ /**
69
+ * The runtime that the application is running in.
70
+ *
71
+ * @defaultValue "nodejs"
72
+ */
73
+ RUNTIME: "nodejs" | "deno" | "workerd" | "browser";
74
+ }
75
+ //#endregion
76
+ export { OpenTelemetryEnv };
77
+ //# sourceMappingURL=env.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.cts","names":[],"sources":["../../src/types/env.ts"],"mappings":";;;;;AA+BA;;;;;;;;;UAAiB,gBAAA,SAAyB,YAAA;EA2C/B;;;EAAA,SAvCA,iBAAA;EA0ET;;;;;EAAA,SAnES,kCAAA;;;;;;WAOA,mBAAA;;;;;;WAWA,uBAAA;;;;;;WAOA,mBAAA;;;;;;WAOA,gBAAA;;;;;;WAOA,qBAAA;;;;;;WAOA,cAAA;;;;;;WAcA,iBAAA;;;;;;EAOT,OAAA;AAAA"}
@@ -0,0 +1,77 @@
1
+ import { EnvInterface } from "@powerlines/plugin-env/types/env";
2
+
3
+ //#region src/types/env.d.ts
4
+ /**
5
+ * The base environment configuration used by Powerlines applications
6
+ *
7
+ * @remarks
8
+ * This interface is used to define the environment variables, configuration options, and runtime settings used by applications. It is used to provide type safety, autocompletion, and default values for the environment variables. The comments of each variable are used to provide documentation descriptions when running the \`powerlines docs\` command.
9
+ *
10
+ * @categoryDescription Platform
11
+ * The name of the platform the configuration parameter is intended for use in.
12
+ *
13
+ * @showCategories
14
+ */
15
+ interface OpenTelemetryEnv extends EnvInterface {
16
+ /**
17
+ * The name of the service. If none if provided, the plugin will attempt to use the value of the {@link EnvInterface.APP_NAME} configuration option.
18
+ */
19
+ readonly OTEL_SERVICE_NAME?: string;
20
+ /**
21
+ * The OTLP traces endpoint URL.
22
+ *
23
+ * @defaultValue "http://localhost:4318/v1/traces"
24
+ */
25
+ readonly OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: string;
26
+ /**
27
+ * The supported trace sampler to use.
28
+ *
29
+ * @defaultValue "always_on"
30
+ */
31
+ readonly OTEL_TRACES_SAMPLER: "always_on" | "always_off" | "traceidratio" | "parentbased_traceidratio";
32
+ /**
33
+ * The argument for the trace sampler. For example, if using the "traceidratio" sampler, this would be a number between 0 and 1 representing the sampling ratio.
34
+ *
35
+ * @defaultValue 1
36
+ */
37
+ readonly OTEL_TRACES_SAMPLER_ARG: number;
38
+ /**
39
+ * A comma-separated list of trace exporter types to use. Supported values include "http" and "console".
40
+ *
41
+ * @defaultValue "http"
42
+ */
43
+ readonly OTEL_EXPORTER_TYPES?: string;
44
+ /**
45
+ * A comma-separated list of trace propagator types to use. Supported values include "tracecontext" and "baggage".
46
+ *
47
+ * @defaultValue "tracecontext,baggage"
48
+ */
49
+ readonly OTEL_PROPAGATORS?: string;
50
+ /**
51
+ * A comma-separated list of trace instrumentations to use. Supported values include "http", "express", and "graphql".
52
+ *
53
+ * @defaultValue "http,express"
54
+ */
55
+ readonly OTEL_INSTRUMENTATIONS?: string;
56
+ /**
57
+ * The log level for OpenTelemetry SDK diagnostics. If not set, the {@link EnvInterface.LOG_LEVEL} variable will be used to determine the log level for diagnostics.
58
+ *
59
+ * @defaultValue "INFO"
60
+ */
61
+ readonly OTEL_LOG_LEVEL?: "ALL" | "VERBOSE" | "DEBUG" | "INFO" | "WARN" | "ERROR" | "NONE";
62
+ /**
63
+ * A boolean flag to disable the OpenTelemetry SDK. When set to "true", the plugin will not inject any OpenTelemetry code or configuration into the application.
64
+ *
65
+ * @defaultValue false
66
+ */
67
+ readonly OTEL_SDK_DISABLED: boolean;
68
+ /**
69
+ * The runtime that the application is running in.
70
+ *
71
+ * @defaultValue "nodejs"
72
+ */
73
+ RUNTIME: "nodejs" | "deno" | "workerd" | "browser";
74
+ }
75
+ //#endregion
76
+ export { OpenTelemetryEnv };
77
+ //# sourceMappingURL=env.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.mts","names":[],"sources":["../../src/types/env.ts"],"mappings":";;;;;AA+BA;;;;;;;;;UAAiB,gBAAA,SAAyB,YAAA;EA2C/B;;;EAAA,SAvCA,iBAAA;EA0ET;;;;;EAAA,SAnES,kCAAA;;;;;;WAOA,mBAAA;;;;;;WAWA,uBAAA;;;;;;WAOA,mBAAA;;;;;;WAOA,gBAAA;;;;;;WAOA,qBAAA;;;;;;WAOA,cAAA;;;;;;WAcA,iBAAA;;;;;;EAOT,OAAA;AAAA"}
@@ -0,0 +1,2 @@
1
+ export{};
2
+ //# sourceMappingURL=env.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.mjs","names":[],"sources":["../../src/types/env.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { EnvInterface } from \"@powerlines/plugin-env/types/env\";\n\n/**\n * The base environment configuration used by Powerlines applications\n *\n * @remarks\n * This interface is used to define the environment variables, configuration options, and runtime settings used by applications. It is used to provide type safety, autocompletion, and default values for the environment variables. The comments of each variable are used to provide documentation descriptions when running the \\`powerlines docs\\` command.\n *\n * @categoryDescription Platform\n * The name of the platform the configuration parameter is intended for use in.\n *\n * @showCategories\n */\nexport interface OpenTelemetryEnv extends EnvInterface {\n /**\n * The name of the service. If none if provided, the plugin will attempt to use the value of the {@link EnvInterface.APP_NAME} configuration option.\n */\n readonly OTEL_SERVICE_NAME?: string;\n\n /**\n * The OTLP traces endpoint URL.\n *\n * @defaultValue \"http://localhost:4318/v1/traces\"\n */\n readonly OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: string;\n\n /**\n * The supported trace sampler to use.\n *\n * @defaultValue \"always_on\"\n */\n readonly OTEL_TRACES_SAMPLER:\n | \"always_on\"\n | \"always_off\"\n | \"traceidratio\"\n | \"parentbased_traceidratio\";\n\n /**\n * The argument for the trace sampler. For example, if using the \"traceidratio\" sampler, this would be a number between 0 and 1 representing the sampling ratio.\n *\n * @defaultValue 1\n */\n readonly OTEL_TRACES_SAMPLER_ARG: number;\n\n /**\n * A comma-separated list of trace exporter types to use. Supported values include \"http\" and \"console\".\n *\n * @defaultValue \"http\"\n */\n readonly OTEL_EXPORTER_TYPES?: string;\n\n /**\n * A comma-separated list of trace propagator types to use. Supported values include \"tracecontext\" and \"baggage\".\n *\n * @defaultValue \"tracecontext,baggage\"\n */\n readonly OTEL_PROPAGATORS?: string;\n\n /**\n * A comma-separated list of trace instrumentations to use. Supported values include \"http\", \"express\", and \"graphql\".\n *\n * @defaultValue \"http,express\"\n */\n readonly OTEL_INSTRUMENTATIONS?: string;\n\n /**\n * The log level for OpenTelemetry SDK diagnostics. If not set, the {@link EnvInterface.LOG_LEVEL} variable will be used to determine the log level for diagnostics.\n *\n * @defaultValue \"INFO\"\n */\n readonly OTEL_LOG_LEVEL?:\n | \"ALL\"\n | \"VERBOSE\"\n | \"DEBUG\"\n | \"INFO\"\n | \"WARN\"\n | \"ERROR\"\n | \"NONE\";\n\n /**\n * A boolean flag to disable the OpenTelemetry SDK. When set to \"true\", the plugin will not inject any OpenTelemetry code or configuration into the application.\n *\n * @defaultValue false\n */\n readonly OTEL_SDK_DISABLED: boolean;\n\n /**\n * The runtime that the application is running in.\n *\n * @defaultValue \"nodejs\"\n */\n RUNTIME: \"nodejs\" | \"deno\" | \"workerd\" | \"browser\";\n}\n"],"mappings":""}
File without changes
@@ -0,0 +1,3 @@
1
+ import { AttributesFromHeaderFunc, AttributesFromHeaders, Configuration, FetchInstrumentationConfig, InstrumentationConfiguration, InstrumentationOptionOrName, OTLPExporterConfig, OpenTelemetryPluginContext, OpenTelemetryPluginOptions, OpenTelemetryPluginResolvedConfig, OpenTelemetryPluginUserConfig, PropagatorOrName, SampleOrName, SpanExporterOrName, SpanProcessorOrName } from "./plugin.cjs";
2
+ import { OpenTelemetryEnv } from "./env.cjs";
3
+ export { AttributesFromHeaderFunc, AttributesFromHeaders, Configuration, FetchInstrumentationConfig, InstrumentationConfiguration, InstrumentationOptionOrName, OTLPExporterConfig, OpenTelemetryEnv, OpenTelemetryPluginContext, OpenTelemetryPluginOptions, OpenTelemetryPluginResolvedConfig, OpenTelemetryPluginUserConfig, PropagatorOrName, SampleOrName, SpanExporterOrName, SpanProcessorOrName };
@@ -0,0 +1,3 @@
1
+ import { AttributesFromHeaderFunc, AttributesFromHeaders, Configuration, FetchInstrumentationConfig, InstrumentationConfiguration, InstrumentationOptionOrName, OTLPExporterConfig, OpenTelemetryPluginContext, OpenTelemetryPluginOptions, OpenTelemetryPluginResolvedConfig, OpenTelemetryPluginUserConfig, PropagatorOrName, SampleOrName, SpanExporterOrName, SpanProcessorOrName } from "./plugin.mjs";
2
+ import { OpenTelemetryEnv } from "./env.mjs";
3
+ export { AttributesFromHeaderFunc, AttributesFromHeaders, Configuration, FetchInstrumentationConfig, InstrumentationConfiguration, InstrumentationOptionOrName, OTLPExporterConfig, OpenTelemetryEnv, OpenTelemetryPluginContext, OpenTelemetryPluginOptions, OpenTelemetryPluginResolvedConfig, OpenTelemetryPluginUserConfig, PropagatorOrName, SampleOrName, SpanExporterOrName, SpanProcessorOrName };
@@ -0,0 +1 @@
1
+ export{};
File without changes
@@ -0,0 +1,139 @@
1
+ import { Attributes, ContextManager, TextMapGetter, TextMapPropagator } from "@opentelemetry/api";
2
+ import { Instrumentation } from "@opentelemetry/instrumentation";
3
+ import { ResourceDetector } from "@opentelemetry/resources";
4
+ import { LogRecordProcessor } from "@opentelemetry/sdk-logs";
5
+ import { MetricReader, ViewOptions } from "@opentelemetry/sdk-metrics";
6
+ import { IdGenerator, Sampler, SpanExporter, SpanLimits, SpanProcessor } from "@opentelemetry/sdk-trace-base";
7
+ import { AlloyPluginContext, AlloyPluginOptions, AlloyPluginResolvedConfig, AlloyPluginUserConfig } from "@powerlines/plugin-alloy/types";
8
+ import { AutoMDPluginOptions } from "@powerlines/plugin-automd/types/plugin";
9
+ import { BabelPluginContext, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
10
+ import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig } from "@powerlines/plugin-env";
11
+
12
+ //#region src/types/plugin.d.ts
13
+ /**
14
+ * Configuration for the OTLP trace exporters.
15
+ */
16
+ interface OTLPExporterConfig {
17
+ headers?: Record<string, unknown>;
18
+ url?: string;
19
+ }
20
+ type PropagatorOrName = TextMapPropagator | "auto" | "none" | "tracecontext" | "baggage";
21
+ type SampleOrName = Sampler | "auto" | "always_off" | "always_on" | "parentbased_always_off" | "parentbased_always_on" | "parentbased_traceidratio" | "traceidratio";
22
+ type SpanProcessorOrName = SpanProcessor | "auto";
23
+ type SpanExporterOrName = SpanExporter | "auto";
24
+ type InstrumentationOptionOrName = Instrumentation | "fetch" | "auto";
25
+ interface FetchInstrumentationConfig {
26
+ /** URL matchers (string prefix or regex) to ignore from tracing. */
27
+ ignoreUrls?: Array<string | RegExp>;
28
+ /** URL matchers for which the tracing context should be propagated. */
29
+ propagateContextUrls?: Array<string | RegExp>;
30
+ /** URL matchers to exclude from context propagation. */
31
+ dontPropagateContextUrls?: Array<string | RegExp>;
32
+ /** Template string for the "resource.name" attribute. Use `{attr}` expressions. */
33
+ resourceNameTemplate?: string;
34
+ }
35
+ interface InstrumentationConfiguration {
36
+ fetch?: FetchInstrumentationConfig;
37
+ }
38
+ type AttributesFromHeaderFunc = <Carrier = unknown>(headers: Carrier, getter: TextMapGetter<Carrier>) => Attributes | undefined;
39
+ type AttributesFromHeaders = Record<string, string> | AttributesFromHeaderFunc;
40
+ /**
41
+ * OpenTelemetry SDK configuration. Mirrors the `@vercel/otel` `Configuration`
42
+ * interface, allowing the same options to be passed to `registerOTel`.
43
+ */
44
+ interface Configuration {
45
+ /**
46
+ * The name of your service, used as the app name in many OpenTelemetry
47
+ * backends. Can be overridden by the `OTEL_SERVICE_NAME` environment variable.
48
+ */
49
+ serviceName?: string;
50
+ /**
51
+ * Additional resource attributes to apply to all spans. By default the
52
+ * plugin configures standard OpenTelemetry resource attributes such as
53
+ * `deployment.environment.name`, `cloud.region`, `process.runtime.name`,
54
+ * `vcs.ref.head.name`, `vcs.ref.head.revision`, `vcs.repository.name`,
55
+ * and `deployment.id`.
56
+ */
57
+ attributes?: Attributes;
58
+ /**
59
+ * Compute root span attributes based on request headers.
60
+ * A map with keys as attribute names and values as header names, or a
61
+ * function that takes an opaque headers object and returns attributes.
62
+ */
63
+ attributesFromHeaders?: AttributesFromHeaders;
64
+ /** Custom resource detectors. Defaults to `[envDetector]`. */
65
+ resourceDetectors?: ResourceDetector[];
66
+ /** Whether to auto-detect resources via detectors. Defaults to `true`. */
67
+ autoDetectResources?: boolean;
68
+ /**
69
+ * Set of instrumentations to enable.
70
+ * Defaults to `["auto"]` which enables the built-in fetch instrumentation.
71
+ */
72
+ instrumentations?: InstrumentationOptionOrName[];
73
+ /**
74
+ * Customize configuration for predefined instrumentations
75
+ * (e.g. `fetch`).
76
+ */
77
+ instrumentationConfig?: InstrumentationConfiguration;
78
+ /** Custom context manager. Defaults to `AsyncLocalStorageContextManager`. */
79
+ contextManager?: ContextManager;
80
+ /** Custom ID generator. Defaults to `RandomIdGenerator`. */
81
+ idGenerator?: IdGenerator;
82
+ /**
83
+ * Propagators for extending inbound and outbound contexts.
84
+ * Defaults to W3C Trace Context + Baggage propagators.
85
+ * Can also be configured via `OTEL_PROPAGATORS` env var.
86
+ */
87
+ propagators?: PropagatorOrName[];
88
+ /**
89
+ * Sampler to decide which requests to trace.
90
+ * Defaults to `"always_on"` (all requests).
91
+ * Can also be configured via `OTEL_TRACES_SAMPLER` env var.
92
+ */
93
+ traceSampler?: SampleOrName;
94
+ /**
95
+ * Span processors to use. Defaults to `"auto"` which auto-configures the
96
+ * best export mechanism for the environment.
97
+ */
98
+ spanProcessors?: SpanProcessorOrName[];
99
+ /**
100
+ * Custom trace exporter. Defaults to `"auto"` which selects the best
101
+ * exporter for the environment (OTLP HTTP if `OTEL_EXPORTER_OTLP_ENDPOINT`
102
+ * is set, etc.).
103
+ */
104
+ traceExporter?: SpanExporterOrName;
105
+ /** Optional span limits configuration. */
106
+ spanLimits?: SpanLimits;
107
+ /** Log record processors to enable log recording. */
108
+ logRecordProcessors?: LogRecordProcessor[];
109
+ /** Metric readers for metrics collection. */
110
+ metricReaders?: MetricReader[];
111
+ /** Metric views for SDK-level metric filtering/aggregation. */
112
+ views?: ViewOptions[];
113
+ }
114
+ interface OpenTelemetryPluginOptions extends Configuration {
115
+ /**
116
+ * AutoMD configuration options to allow injecting OpenTelemetry documentation
117
+ * into a markdown file such as a README.md.
118
+ */
119
+ automd?: AutoMDPluginOptions;
120
+ /**
121
+ * Alloy configuration options to use when generating OpenTelemetry runtime
122
+ * code into the source tree.
123
+ */
124
+ alloy?: AlloyPluginOptions;
125
+ /**
126
+ * Env plugin options to use for configuring environment variable loading and injection, which can be used to configure the OpenTelemetry SDK via environment variables.
127
+ */
128
+ env?: EnvPluginOptions;
129
+ }
130
+ type OpenTelemetryPluginUserConfig = BabelPluginUserConfig & AlloyPluginUserConfig & EnvPluginUserConfig & {
131
+ openTelemetry: OpenTelemetryPluginOptions;
132
+ };
133
+ type OpenTelemetryPluginResolvedConfig = BabelPluginResolvedConfig & AlloyPluginResolvedConfig & EnvPluginResolvedConfig & {
134
+ openTelemetry: OpenTelemetryPluginOptions;
135
+ };
136
+ interface OpenTelemetryPluginContext<TResolvedConfig extends OpenTelemetryPluginResolvedConfig = OpenTelemetryPluginResolvedConfig> extends BabelPluginContext<TResolvedConfig>, AlloyPluginContext<TResolvedConfig>, EnvPluginContext<TResolvedConfig> {}
137
+ //#endregion
138
+ export { AttributesFromHeaderFunc, AttributesFromHeaders, Configuration, FetchInstrumentationConfig, InstrumentationConfiguration, InstrumentationOptionOrName, OTLPExporterConfig, OpenTelemetryPluginContext, OpenTelemetryPluginOptions, OpenTelemetryPluginResolvedConfig, OpenTelemetryPluginUserConfig, PropagatorOrName, SampleOrName, SpanExporterOrName, SpanProcessorOrName };
139
+ //# sourceMappingURL=plugin.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;;;;;;;AA2DA;UAAiB,kBAAA;EACf,OAAA,GAAU,MAAA;EACV,GAAA;AAAA;AAAA,KAKU,gBAAA,GACR,iBAAA;AAAA,KAMQ,YAAA,GACR,OAAA;AAAA,KASQ,mBAAA,GAAsB,aAAA;AAAA,KAEtB,kBAAA,GAAqB,YAAA;AAAA,KAErB,2BAAA,GAA8B,eAAA;AAAA,UAIzB,0BAAA;;EAEf,UAAA,GAAa,KAAA,UAAe,MAAA;EA1BT;EA4BnB,oBAAA,GAAuB,KAAA,UAAe,MAAA;EAtBhB;EAwBtB,wBAAA,GAA2B,KAAA,UAAe,MAAA;EAvBxC;EAyBF,oBAAA;AAAA;AAAA,UAGe,4BAAA;EACf,KAAA,GAAQ,0BAAA;AAAA;AAAA,KAKE,wBAAA,uBACV,OAAA,EAAS,OAAA,EACT,MAAA,EAAQ,aAAA,CAAc,OAAA,MACnB,UAAA;AAAA,KAEO,qBAAA,GACR,MAAA,mBACA,wBAAA;;;;;UAQa,aAAA;EApCsB;;;;EAyCrC,WAAA;EArCyC;;;;;;;EA8CzC,UAAA,GAAa,UAAA;EAxCmB;;;;;EA+ChC,qBAAA,GAAwB,qBAAA;EAjDD;EAoDvB,iBAAA,GAAoB,gBAAA;EAlDpB;EAqDA,mBAAA;EArD0C;;;;EA2D1C,gBAAA,GAAmB,2BAAA;EAtDwB;;;;EA4D3C,qBAAA,GAAwB,4BAAA;EAtDU;EAyDlC,cAAA,GAAiB,cAAA;EAxDR;EA2DT,WAAA,GAAc,WAAA;EA1DN;;;;;EAiER,WAAA,GAAc,gBAAA;EAlEd;;;;;EAyEA,YAAA,GAAe,YAAA;EAvEF;AAEf;;;EA2EE,cAAA,GAAiB,mBAAA;EAzES;AAQ5B;;;;EAwEE,aAAA,GAAgB,kBAAA;EAhDI;EAmDpB,UAAA,GAAa,UAAA;EApCW;EAuCxB,mBAAA,GAAsB,kBAAA;EAjCR;EAoCd,aAAA,GAAgB,YAAA;EAtBD;EAyBf,KAAA,GAAQ,WAAA;AAAA;AAAA,UAKO,0BAAA,SAAmC,aAAA;EAX5B;;;;EAgBtB,MAAA,GAAS,mBAAA;EAzFT;;;;EA+FA,KAAA,GAAQ,kBAAA;EA5ER;;;EAiFA,GAAA,GAAM,gBAAA;AAAA;AAAA,KAGI,6BAAA,GAAgC,qBAAA,GAC1C,qBAAA,GACA,mBAAA;EACE,aAAA,EAAe,0BAAA;AAAA;AAAA,KAGP,iCAAA,GAAoC,yBAAA,GAC9C,yBAAA,GACA,uBAAA;EACE,aAAA,EAAe,0BAAA;AAAA;AAAA,UAGF,0BAAA,yBACS,iCAAA,GACtB,iCAAA,UAGA,kBAAA,CAAmB,eAAA,GACnB,kBAAA,CAAmB,eAAA,GACnB,gBAAA,CAAiB,eAAA"}
@@ -0,0 +1,139 @@
1
+ import { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig } from "@powerlines/plugin-env";
2
+ import { Attributes, ContextManager, TextMapGetter, TextMapPropagator } from "@opentelemetry/api";
3
+ import { Instrumentation } from "@opentelemetry/instrumentation";
4
+ import { ResourceDetector } from "@opentelemetry/resources";
5
+ import { LogRecordProcessor } from "@opentelemetry/sdk-logs";
6
+ import { MetricReader, ViewOptions } from "@opentelemetry/sdk-metrics";
7
+ import { IdGenerator, Sampler, SpanExporter, SpanLimits, SpanProcessor } from "@opentelemetry/sdk-trace-base";
8
+ import { AlloyPluginContext, AlloyPluginOptions, AlloyPluginResolvedConfig, AlloyPluginUserConfig } from "@powerlines/plugin-alloy/types";
9
+ import { AutoMDPluginOptions } from "@powerlines/plugin-automd/types/plugin";
10
+ import { BabelPluginContext, BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types";
11
+
12
+ //#region src/types/plugin.d.ts
13
+ /**
14
+ * Configuration for the OTLP trace exporters.
15
+ */
16
+ interface OTLPExporterConfig {
17
+ headers?: Record<string, unknown>;
18
+ url?: string;
19
+ }
20
+ type PropagatorOrName = TextMapPropagator | "auto" | "none" | "tracecontext" | "baggage";
21
+ type SampleOrName = Sampler | "auto" | "always_off" | "always_on" | "parentbased_always_off" | "parentbased_always_on" | "parentbased_traceidratio" | "traceidratio";
22
+ type SpanProcessorOrName = SpanProcessor | "auto";
23
+ type SpanExporterOrName = SpanExporter | "auto";
24
+ type InstrumentationOptionOrName = Instrumentation | "fetch" | "auto";
25
+ interface FetchInstrumentationConfig {
26
+ /** URL matchers (string prefix or regex) to ignore from tracing. */
27
+ ignoreUrls?: Array<string | RegExp>;
28
+ /** URL matchers for which the tracing context should be propagated. */
29
+ propagateContextUrls?: Array<string | RegExp>;
30
+ /** URL matchers to exclude from context propagation. */
31
+ dontPropagateContextUrls?: Array<string | RegExp>;
32
+ /** Template string for the "resource.name" attribute. Use `{attr}` expressions. */
33
+ resourceNameTemplate?: string;
34
+ }
35
+ interface InstrumentationConfiguration {
36
+ fetch?: FetchInstrumentationConfig;
37
+ }
38
+ type AttributesFromHeaderFunc = <Carrier = unknown>(headers: Carrier, getter: TextMapGetter<Carrier>) => Attributes | undefined;
39
+ type AttributesFromHeaders = Record<string, string> | AttributesFromHeaderFunc;
40
+ /**
41
+ * OpenTelemetry SDK configuration. Mirrors the `@vercel/otel` `Configuration`
42
+ * interface, allowing the same options to be passed to `registerOTel`.
43
+ */
44
+ interface Configuration {
45
+ /**
46
+ * The name of your service, used as the app name in many OpenTelemetry
47
+ * backends. Can be overridden by the `OTEL_SERVICE_NAME` environment variable.
48
+ */
49
+ serviceName?: string;
50
+ /**
51
+ * Additional resource attributes to apply to all spans. By default the
52
+ * plugin configures standard OpenTelemetry resource attributes such as
53
+ * `deployment.environment.name`, `cloud.region`, `process.runtime.name`,
54
+ * `vcs.ref.head.name`, `vcs.ref.head.revision`, `vcs.repository.name`,
55
+ * and `deployment.id`.
56
+ */
57
+ attributes?: Attributes;
58
+ /**
59
+ * Compute root span attributes based on request headers.
60
+ * A map with keys as attribute names and values as header names, or a
61
+ * function that takes an opaque headers object and returns attributes.
62
+ */
63
+ attributesFromHeaders?: AttributesFromHeaders;
64
+ /** Custom resource detectors. Defaults to `[envDetector]`. */
65
+ resourceDetectors?: ResourceDetector[];
66
+ /** Whether to auto-detect resources via detectors. Defaults to `true`. */
67
+ autoDetectResources?: boolean;
68
+ /**
69
+ * Set of instrumentations to enable.
70
+ * Defaults to `["auto"]` which enables the built-in fetch instrumentation.
71
+ */
72
+ instrumentations?: InstrumentationOptionOrName[];
73
+ /**
74
+ * Customize configuration for predefined instrumentations
75
+ * (e.g. `fetch`).
76
+ */
77
+ instrumentationConfig?: InstrumentationConfiguration;
78
+ /** Custom context manager. Defaults to `AsyncLocalStorageContextManager`. */
79
+ contextManager?: ContextManager;
80
+ /** Custom ID generator. Defaults to `RandomIdGenerator`. */
81
+ idGenerator?: IdGenerator;
82
+ /**
83
+ * Propagators for extending inbound and outbound contexts.
84
+ * Defaults to W3C Trace Context + Baggage propagators.
85
+ * Can also be configured via `OTEL_PROPAGATORS` env var.
86
+ */
87
+ propagators?: PropagatorOrName[];
88
+ /**
89
+ * Sampler to decide which requests to trace.
90
+ * Defaults to `"always_on"` (all requests).
91
+ * Can also be configured via `OTEL_TRACES_SAMPLER` env var.
92
+ */
93
+ traceSampler?: SampleOrName;
94
+ /**
95
+ * Span processors to use. Defaults to `"auto"` which auto-configures the
96
+ * best export mechanism for the environment.
97
+ */
98
+ spanProcessors?: SpanProcessorOrName[];
99
+ /**
100
+ * Custom trace exporter. Defaults to `"auto"` which selects the best
101
+ * exporter for the environment (OTLP HTTP if `OTEL_EXPORTER_OTLP_ENDPOINT`
102
+ * is set, etc.).
103
+ */
104
+ traceExporter?: SpanExporterOrName;
105
+ /** Optional span limits configuration. */
106
+ spanLimits?: SpanLimits;
107
+ /** Log record processors to enable log recording. */
108
+ logRecordProcessors?: LogRecordProcessor[];
109
+ /** Metric readers for metrics collection. */
110
+ metricReaders?: MetricReader[];
111
+ /** Metric views for SDK-level metric filtering/aggregation. */
112
+ views?: ViewOptions[];
113
+ }
114
+ interface OpenTelemetryPluginOptions extends Configuration {
115
+ /**
116
+ * AutoMD configuration options to allow injecting OpenTelemetry documentation
117
+ * into a markdown file such as a README.md.
118
+ */
119
+ automd?: AutoMDPluginOptions;
120
+ /**
121
+ * Alloy configuration options to use when generating OpenTelemetry runtime
122
+ * code into the source tree.
123
+ */
124
+ alloy?: AlloyPluginOptions;
125
+ /**
126
+ * Env plugin options to use for configuring environment variable loading and injection, which can be used to configure the OpenTelemetry SDK via environment variables.
127
+ */
128
+ env?: EnvPluginOptions;
129
+ }
130
+ type OpenTelemetryPluginUserConfig = BabelPluginUserConfig & AlloyPluginUserConfig & EnvPluginUserConfig & {
131
+ openTelemetry: OpenTelemetryPluginOptions;
132
+ };
133
+ type OpenTelemetryPluginResolvedConfig = BabelPluginResolvedConfig & AlloyPluginResolvedConfig & EnvPluginResolvedConfig & {
134
+ openTelemetry: OpenTelemetryPluginOptions;
135
+ };
136
+ interface OpenTelemetryPluginContext<TResolvedConfig extends OpenTelemetryPluginResolvedConfig = OpenTelemetryPluginResolvedConfig> extends BabelPluginContext<TResolvedConfig>, AlloyPluginContext<TResolvedConfig>, EnvPluginContext<TResolvedConfig> {}
137
+ //#endregion
138
+ export { AttributesFromHeaderFunc, AttributesFromHeaders, Configuration, FetchInstrumentationConfig, InstrumentationConfiguration, InstrumentationOptionOrName, OTLPExporterConfig, OpenTelemetryPluginContext, OpenTelemetryPluginOptions, OpenTelemetryPluginResolvedConfig, OpenTelemetryPluginUserConfig, PropagatorOrName, SampleOrName, SpanExporterOrName, SpanProcessorOrName };
139
+ //# sourceMappingURL=plugin.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;;;;;;;;;AA2DA;UAAiB,kBAAA;EACf,OAAA,GAAU,MAAA;EACV,GAAA;AAAA;AAAA,KAKU,gBAAA,GACR,iBAAA;AAAA,KAMQ,YAAA,GACR,OAAA;AAAA,KASQ,mBAAA,GAAsB,aAAA;AAAA,KAEtB,kBAAA,GAAqB,YAAA;AAAA,KAErB,2BAAA,GAA8B,eAAA;AAAA,UAIzB,0BAAA;;EAEf,UAAA,GAAa,KAAA,UAAe,MAAA;EA1BT;EA4BnB,oBAAA,GAAuB,KAAA,UAAe,MAAA;EAtBhB;EAwBtB,wBAAA,GAA2B,KAAA,UAAe,MAAA;EAvBxC;EAyBF,oBAAA;AAAA;AAAA,UAGe,4BAAA;EACf,KAAA,GAAQ,0BAAA;AAAA;AAAA,KAKE,wBAAA,uBACV,OAAA,EAAS,OAAA,EACT,MAAA,EAAQ,aAAA,CAAc,OAAA,MACnB,UAAA;AAAA,KAEO,qBAAA,GACR,MAAA,mBACA,wBAAA;;;;;UAQa,aAAA;EApCsB;;;;EAyCrC,WAAA;EArCyC;;;;;;;EA8CzC,UAAA,GAAa,UAAA;EAxCmB;;;;;EA+ChC,qBAAA,GAAwB,qBAAA;EAjDD;EAoDvB,iBAAA,GAAoB,gBAAA;EAlDpB;EAqDA,mBAAA;EArD0C;;;;EA2D1C,gBAAA,GAAmB,2BAAA;EAtDwB;;;;EA4D3C,qBAAA,GAAwB,4BAAA;EAtDU;EAyDlC,cAAA,GAAiB,cAAA;EAxDR;EA2DT,WAAA,GAAc,WAAA;EA1DN;;;;;EAiER,WAAA,GAAc,gBAAA;EAlEd;;;;;EAyEA,YAAA,GAAe,YAAA;EAvEF;AAEf;;;EA2EE,cAAA,GAAiB,mBAAA;EAzES;AAQ5B;;;;EAwEE,aAAA,GAAgB,kBAAA;EAhDI;EAmDpB,UAAA,GAAa,UAAA;EApCW;EAuCxB,mBAAA,GAAsB,kBAAA;EAjCR;EAoCd,aAAA,GAAgB,YAAA;EAtBD;EAyBf,KAAA,GAAQ,WAAA;AAAA;AAAA,UAKO,0BAAA,SAAmC,aAAA;EAX5B;;;;EAgBtB,MAAA,GAAS,mBAAA;EAzFT;;;;EA+FA,KAAA,GAAQ,kBAAA;EA5ER;;;EAiFA,GAAA,GAAM,gBAAA;AAAA;AAAA,KAGI,6BAAA,GAAgC,qBAAA,GAC1C,qBAAA,GACA,mBAAA;EACE,aAAA,EAAe,0BAAA;AAAA;AAAA,KAGP,iCAAA,GAAoC,yBAAA,GAC9C,yBAAA,GACA,uBAAA;EACE,aAAA,EAAe,0BAAA;AAAA;AAAA,UAGF,0BAAA,yBACS,iCAAA,GACtB,iCAAA,UAGA,kBAAA,CAAmB,eAAA,GACnB,kBAAA,CAAmB,eAAA,GACnB,gBAAA,CAAiB,eAAA"}
@@ -0,0 +1 @@
1
+ export{};