@powerlines/plugin-open-telemetry 0.1.4 → 0.1.5

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 +1,29 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
@@ -1 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./trace-builtin.cjs`);exports.TraceBuiltin=e.TraceBuiltin;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_components_trace_builtin = require('./trace-builtin.cjs');
3
+
4
+ exports.TraceBuiltin = require_components_trace_builtin.TraceBuiltin;
@@ -1 +1,3 @@
1
- import{TraceBuiltin as e}from"./trace-builtin.mjs";export{e as TraceBuiltin};
1
+ import { TraceBuiltin } from "./trace-builtin.mjs";
2
+
3
+ export { TraceBuiltin };
@@ -1,4 +1,130 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`);let t=require(`@alloy-js/core/jsx-runtime`),n=require(`@alloy-js/core`),r=require(`@alloy-js/typescript`),i=require(`@powerlines/plugin-alloy/core`),a=require(`@powerlines/plugin-alloy/core/components/spacing`),o=require(`@powerlines/plugin-alloy/typescript/components/builtin-file`),s=require(`@powerlines/plugin-alloy/typescript/components/tsdoc`),c=require(`defu`);c=e.__toESM(c);function l(e){let[{children:l,imports:u},d]=(0,n.splitProps)(e,[`children`,`imports`]),f=(0,i.usePowerlines)();return(0,t.createComponent)(o.BuiltinFile,(0,t.mergeProps)({id:`trace`,description:`The runtime OpenTelemetry trace module provides registerOTel and getTracer helpers that mirror the @vercel/otel API.`},d,{get imports(){return(0,c.default)({"@opentelemetry/api":[{name:`trace`},{name:`diag`},{name:`propagation`},{name:`context`},{name:`metrics`},{name:`DiagConsoleLogger`},{name:`DiagLogLevel`},{name:`ContextManager`,type:!0},{name:`TextMapPropagator`,type:!0},{name:`Attributes`,type:!0}],"@opentelemetry/api-logs":[{name:`logs`}],"@opentelemetry/context-async-hooks":[{name:`AsyncLocalStorageContextManager`}],"@opentelemetry/core":[{name:`CompositePropagator`},{name:`ExportResult`,type:!0},{name:`W3CBaggagePropagator`},{name:`W3CTraceContextPropagator`},{name:`parseKeyPairsIntoRecord`}],"@opentelemetry/instrumentation":[{name:`registerInstrumentations`},{name:`Instrumentation`,type:!0}],"@opentelemetry/resources":[{name:`resourceFromAttributes`},{name:`detectResources`},{name:`envDetector`}],"@opentelemetry/sdk-logs":[{name:`LoggerProvider`}],"@opentelemetry/sdk-metrics":[{name:`MeterProvider`}],"@opentelemetry/sdk-trace-base":[{name:`BasicTracerProvider`},{name:`BatchSpanProcessor`},{name:`RandomIdGenerator`},{name:`AlwaysOnSampler`},{name:`AlwaysOffSampler`},{name:`ParentBasedSampler`},{name:`TraceIdRatioBasedSampler`},{name:`ReadableSpan`,type:!0},{name:`Sampler`,type:!0},{name:`SpanExporter`,type:!0},{name:`SpanProcessor`,type:!0}],"@powerlines/plugin-open-telemetry":[{name:`Configuration`,type:!0}],"@opentelemetry/exporter-trace-otlp-http":[{name:`OTLPTraceExporter`}]},u??{})},builtinImports:{env:[`env`]},get children(){return[(0,t.createComponent)(s.TSDoc,{heading:`Configuration for the OTLP HTTP trace exporters.`,get children(){return[(0,t.createComponent)(s.TSDocParam,{name:`url`,children:`The URL of the OTLP collector endpoint. Defaults to http://localhost:4318/v1/traces.`}),(0,t.createComponent)(s.TSDocParam,{name:`headers`,children:`Additional HTTP headers to send with each export request.`})]}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.TSDoc,{heading:"OTLP trace exporter using the `http/json` protocol. Compatible with the Edge runtime. Mirrors `OTLPHttpJsonTraceExporter` from `@vercel/otel`.",get children(){return(0,t.createComponent)(s.TSDocParam,{name:`config`,children:`Optional exporter configuration (url, headers).`})}}),n.code`
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
4
+ let _alloy_js_core = require("@alloy-js/core");
5
+ let _alloy_js_typescript = require("@alloy-js/typescript");
6
+ let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
7
+ let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
8
+ let _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
9
+ let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
10
+ let defu = require("defu");
11
+ defu = require_runtime.__toESM(defu);
12
+
13
+ //#region src/components/trace-builtin.tsx
14
+ /**
15
+ * Generates the trace module for the Powerlines project.
16
+ */
17
+ function TraceBuiltin(props) {
18
+ const [{ children, imports }, rest] = (0, _alloy_js_core.splitProps)(props, ["children", "imports"]);
19
+ const context = (0, _powerlines_plugin_alloy_core.usePowerlines)();
20
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({
21
+ id: "trace",
22
+ description: "The runtime OpenTelemetry trace module provides registerOTel and getTracer helpers that mirror the @vercel/otel API."
23
+ }, rest, {
24
+ get imports() {
25
+ return (0, defu.default)({
26
+ "@opentelemetry/api": [
27
+ { name: "trace" },
28
+ { name: "diag" },
29
+ { name: "propagation" },
30
+ { name: "context" },
31
+ { name: "metrics" },
32
+ { name: "DiagConsoleLogger" },
33
+ { name: "DiagLogLevel" },
34
+ {
35
+ name: "ContextManager",
36
+ type: true
37
+ },
38
+ {
39
+ name: "TextMapPropagator",
40
+ type: true
41
+ },
42
+ {
43
+ name: "Attributes",
44
+ type: true
45
+ }
46
+ ],
47
+ "@opentelemetry/api-logs": [{ name: "logs" }],
48
+ "@opentelemetry/context-async-hooks": [{ name: "AsyncLocalStorageContextManager" }],
49
+ "@opentelemetry/core": [
50
+ { name: "CompositePropagator" },
51
+ {
52
+ name: "ExportResult",
53
+ type: true
54
+ },
55
+ { name: "W3CBaggagePropagator" },
56
+ { name: "W3CTraceContextPropagator" },
57
+ { name: "parseKeyPairsIntoRecord" }
58
+ ],
59
+ "@opentelemetry/instrumentation": [{ name: "registerInstrumentations" }, {
60
+ name: "Instrumentation",
61
+ type: true
62
+ }],
63
+ "@opentelemetry/resources": [
64
+ { name: "resourceFromAttributes" },
65
+ { name: "detectResources" },
66
+ { name: "envDetector" }
67
+ ],
68
+ "@opentelemetry/sdk-logs": [{ name: "LoggerProvider" }],
69
+ "@opentelemetry/sdk-metrics": [{ name: "MeterProvider" }],
70
+ "@opentelemetry/sdk-trace-base": [
71
+ { name: "BasicTracerProvider" },
72
+ { name: "BatchSpanProcessor" },
73
+ { name: "RandomIdGenerator" },
74
+ { name: "AlwaysOnSampler" },
75
+ { name: "AlwaysOffSampler" },
76
+ { name: "ParentBasedSampler" },
77
+ { name: "TraceIdRatioBasedSampler" },
78
+ {
79
+ name: "ReadableSpan",
80
+ type: true
81
+ },
82
+ {
83
+ name: "Sampler",
84
+ type: true
85
+ },
86
+ {
87
+ name: "SpanExporter",
88
+ type: true
89
+ },
90
+ {
91
+ name: "SpanProcessor",
92
+ type: true
93
+ }
94
+ ],
95
+ "@powerlines/plugin-open-telemetry": [{
96
+ name: "Configuration",
97
+ type: true
98
+ }],
99
+ "@opentelemetry/exporter-trace-otlp-http": [{ name: "OTLPTraceExporter" }]
100
+ }, imports ?? {});
101
+ },
102
+ builtinImports: { env: ["env"] },
103
+ get children() {
104
+ return [
105
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
106
+ heading: "Configuration for the OTLP HTTP trace exporters.",
107
+ get children() {
108
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
109
+ name: "url",
110
+ children: `The URL of the OTLP collector endpoint. Defaults to http://localhost:4318/v1/traces.`
111
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
112
+ name: "headers",
113
+ children: `Additional HTTP headers to send with each export request.`
114
+ })];
115
+ }
116
+ }),
117
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
118
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
119
+ heading: "OTLP trace exporter using the `http/json` protocol. Compatible with the Edge runtime. Mirrors `OTLPHttpJsonTraceExporter` from `@vercel/otel`.",
120
+ get children() {
121
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
122
+ name: "config",
123
+ children: `Optional exporter configuration (url, headers).`
124
+ });
125
+ }
126
+ }),
127
+ _alloy_js_core.code`
2
128
  export class OTLPHttpJsonTraceExporter implements SpanExporter {
3
129
  private readonly impl: OTLPTraceExporter;
4
130
 
@@ -20,7 +146,18 @@ export class OTLPHttpJsonTraceExporter implements SpanExporter {
20
146
  forceFlush(): Promise<void> {
21
147
  return this.impl.forceFlush?.() ?? Promise.resolve();
22
148
  }
23
- }`,(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.TSDoc,{heading:"OTLP trace exporter using the `http/protobuf` protocol. Compatible with the Edge runtime. Mirrors `OTLPHttpProtoTraceExporter` from `@vercel/otel`.",get children(){return(0,t.createComponent)(s.TSDocParam,{name:`config`,children:`Optional exporter configuration (url, headers). The OTLP collector must support the protobuf encoding.`})}}),n.code`
149
+ }`,
150
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
151
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
152
+ heading: "OTLP trace exporter using the `http/protobuf` protocol. Compatible with the Edge runtime. Mirrors `OTLPHttpProtoTraceExporter` from `@vercel/otel`.",
153
+ get children() {
154
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
155
+ name: "config",
156
+ children: `Optional exporter configuration (url, headers). The OTLP collector must support the protobuf encoding.`
157
+ });
158
+ }
159
+ }),
160
+ _alloy_js_core.code`
24
161
  export class OTLPHttpProtoTraceExporter implements SpanExporter {
25
162
  private readonly impl: OTLPTraceExporter;
26
163
 
@@ -45,7 +182,58 @@ export class OTLPHttpProtoTraceExporter implements SpanExporter {
45
182
  forceFlush(): Promise<void> {
46
183
  return this.impl.forceFlush?.() ?? Promise.resolve();
47
184
  }
48
- }`,(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.TSDoc,{heading:"OpenTelemetry SDK configuration. Mirrors the `@vercel/otel` `Configuration` interface.",get children(){return[(0,t.createComponent)(s.TSDocParam,{name:`serviceName`,children:`The name of your service. Can be overridden by the OTEL_SERVICE_NAME environment variable.`}),(0,t.createComponent)(s.TSDocParam,{name:`attributes`,children:`Additional resource attributes to apply to all spans.`}),(0,t.createComponent)(s.TSDocParam,{name:`propagators`,children:`Propagators for extending inbound and outbound contexts. Defaults to W3C Trace Context + Baggage.`}),(0,t.createComponent)(s.TSDocParam,{name:`traceSampler`,children:`Sampler to decide which requests to trace. Defaults to "always_on".`}),(0,t.createComponent)(s.TSDocParam,{name:`spanProcessors`,children:`Span processors to use. Defaults to "auto" which auto-configures based on environment variables.`}),(0,t.createComponent)(s.TSDocParam,{name:`traceExporter`,children:`Custom trace exporter. Defaults to "auto" which selects the best exporter for the environment.`})]}}),(0,t.createComponent)(s.TSDoc,{heading:"Registers the OpenTelemetry SDK with the specified service name or configuration object. Should be called in `instrumentation.ts` before any other code.",get children(){return(0,t.createComponent)(s.TSDocParam,{name:`optionsOrServiceName`,children:`Either a service name string or a full Configuration object.`})}}),(0,t.createComponent)(r.FunctionDeclaration,{name:`registerOTel`,export:!0,parameters:[{name:`optionsOrServiceName?`,type:`Configuration | string`}],returnType:`void`,get children(){return n.code`
185
+ }`,
186
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
187
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
188
+ heading: "OpenTelemetry SDK configuration. Mirrors the `@vercel/otel` `Configuration` interface.",
189
+ get children() {
190
+ return [
191
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
192
+ name: "serviceName",
193
+ children: `The name of your service. Can be overridden by the OTEL_SERVICE_NAME environment variable.`
194
+ }),
195
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
196
+ name: "attributes",
197
+ children: `Additional resource attributes to apply to all spans.`
198
+ }),
199
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
200
+ name: "propagators",
201
+ children: `Propagators for extending inbound and outbound contexts. Defaults to W3C Trace Context + Baggage.`
202
+ }),
203
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
204
+ name: "traceSampler",
205
+ children: `Sampler to decide which requests to trace. Defaults to "always_on".`
206
+ }),
207
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
208
+ name: "spanProcessors",
209
+ children: `Span processors to use. Defaults to "auto" which auto-configures based on environment variables.`
210
+ }),
211
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
212
+ name: "traceExporter",
213
+ children: `Custom trace exporter. Defaults to "auto" which selects the best exporter for the environment.`
214
+ })
215
+ ];
216
+ }
217
+ }),
218
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
219
+ heading: "Registers the OpenTelemetry SDK with the specified service name or configuration object. Should be called in `instrumentation.ts` before any other code.",
220
+ get children() {
221
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
222
+ name: "optionsOrServiceName",
223
+ children: `Either a service name string or a full Configuration object.`
224
+ });
225
+ }
226
+ }),
227
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
228
+ name: "registerOTel",
229
+ "export": true,
230
+ parameters: [{
231
+ name: "optionsOrServiceName?",
232
+ type: "Configuration | string"
233
+ }],
234
+ returnType: "void",
235
+ get children() {
236
+ return _alloy_js_core.code`
49
237
  let options: Configuration;
50
238
  if (!optionsOrServiceName) {
51
239
  options = {};
@@ -84,7 +272,7 @@ export class OTLPHttpProtoTraceExporter implements SpanExporter {
84
272
  }
85
273
 
86
274
  const idGenerator = options.idGenerator ?? new RandomIdGenerator();
87
- const serviceName = env.OTEL_SERVICE_NAME || options.serviceName || "${f.config.name}";
275
+ const serviceName = env.OTEL_SERVICE_NAME || options.serviceName || "${context.config.name}";
88
276
 
89
277
  const contextManager: ContextManager =
90
278
  options.contextManager ?? new AsyncLocalStorageContextManager();
@@ -227,4 +415,47 @@ export class OTLPHttpProtoTraceExporter implements SpanExporter {
227
415
  );
228
416
  registerInstrumentations({ instrumentations });
229
417
 
230
- diag.info("@powerlines/plugin-open-telemetry: started", serviceName, env.RUNTIME);`}}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(s.TSDoc,{heading:"Returns a named tracer from the global OpenTelemetry TracerProvider. Wraps `trace.getTracer()` for convenience.",get children(){return[(0,t.createComponent)(s.TSDocParam,{name:`name`,children:`The name of the tracer (typically the instrumentation library name or component name).`}),(0,t.createComponent)(s.TSDocParam,{name:`version`,children:`Optional version of the instrumentation library.`})]}}),(0,t.createComponent)(r.FunctionDeclaration,{name:`getTracer`,export:!0,parameters:[{name:`name`,type:`string`},{name:`version`,type:`string`,optional:!0}],returnType:`ReturnType<typeof trace.getTracer>`,children:n.code`return trace.getTracer(name, version);`}),(0,t.createComponent)(a.Spacing,{}),(0,t.createComponent)(n.Show,{get when(){return!!l},children:l})]}}))}exports.TraceBuiltin=l;
418
+ diag.info("@powerlines/plugin-open-telemetry: started", serviceName, env.RUNTIME);`;
419
+ }
420
+ }),
421
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
422
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
423
+ heading: "Returns a named tracer from the global OpenTelemetry TracerProvider. Wraps `trace.getTracer()` for convenience.",
424
+ get children() {
425
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
426
+ name: "name",
427
+ children: `The name of the tracer (typically the instrumentation library name or component name).`
428
+ }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
429
+ name: "version",
430
+ children: `Optional version of the instrumentation library.`
431
+ })];
432
+ }
433
+ }),
434
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
435
+ name: "getTracer",
436
+ "export": true,
437
+ parameters: [{
438
+ name: "name",
439
+ type: "string"
440
+ }, {
441
+ name: "version",
442
+ type: "string",
443
+ optional: true
444
+ }],
445
+ returnType: "ReturnType<typeof trace.getTracer>",
446
+ children: _alloy_js_core.code`return trace.getTracer(name, version);`
447
+ }),
448
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
449
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
450
+ get when() {
451
+ return Boolean(children);
452
+ },
453
+ children
454
+ })
455
+ ];
456
+ }
457
+ }));
458
+ }
459
+
460
+ //#endregion
461
+ exports.TraceBuiltin = TraceBuiltin;
@@ -1,4 +1,127 @@
1
- import{createComponent as e,mergeProps as t}from"@alloy-js/core/jsx-runtime";import{Show as n,code as r,splitProps as i}from"@alloy-js/core";import{FunctionDeclaration as a}from"@alloy-js/typescript";import{usePowerlines as o}from"@powerlines/plugin-alloy/core";import{Spacing as s}from"@powerlines/plugin-alloy/core/components/spacing";import{BuiltinFile as c}from"@powerlines/plugin-alloy/typescript/components/builtin-file";import{TSDoc as l,TSDocParam as u}from"@powerlines/plugin-alloy/typescript/components/tsdoc";import d from"defu";function f(f){let[{children:p,imports:m},h]=i(f,[`children`,`imports`]),g=o();return e(c,t({id:`trace`,description:`The runtime OpenTelemetry trace module provides registerOTel and getTracer helpers that mirror the @vercel/otel API.`},h,{get imports(){return d({"@opentelemetry/api":[{name:`trace`},{name:`diag`},{name:`propagation`},{name:`context`},{name:`metrics`},{name:`DiagConsoleLogger`},{name:`DiagLogLevel`},{name:`ContextManager`,type:!0},{name:`TextMapPropagator`,type:!0},{name:`Attributes`,type:!0}],"@opentelemetry/api-logs":[{name:`logs`}],"@opentelemetry/context-async-hooks":[{name:`AsyncLocalStorageContextManager`}],"@opentelemetry/core":[{name:`CompositePropagator`},{name:`ExportResult`,type:!0},{name:`W3CBaggagePropagator`},{name:`W3CTraceContextPropagator`},{name:`parseKeyPairsIntoRecord`}],"@opentelemetry/instrumentation":[{name:`registerInstrumentations`},{name:`Instrumentation`,type:!0}],"@opentelemetry/resources":[{name:`resourceFromAttributes`},{name:`detectResources`},{name:`envDetector`}],"@opentelemetry/sdk-logs":[{name:`LoggerProvider`}],"@opentelemetry/sdk-metrics":[{name:`MeterProvider`}],"@opentelemetry/sdk-trace-base":[{name:`BasicTracerProvider`},{name:`BatchSpanProcessor`},{name:`RandomIdGenerator`},{name:`AlwaysOnSampler`},{name:`AlwaysOffSampler`},{name:`ParentBasedSampler`},{name:`TraceIdRatioBasedSampler`},{name:`ReadableSpan`,type:!0},{name:`Sampler`,type:!0},{name:`SpanExporter`,type:!0},{name:`SpanProcessor`,type:!0}],"@powerlines/plugin-open-telemetry":[{name:`Configuration`,type:!0}],"@opentelemetry/exporter-trace-otlp-http":[{name:`OTLPTraceExporter`}]},m??{})},builtinImports:{env:[`env`]},get children(){return[e(l,{heading:`Configuration for the OTLP HTTP trace exporters.`,get children(){return[e(u,{name:`url`,children:`The URL of the OTLP collector endpoint. Defaults to http://localhost:4318/v1/traces.`}),e(u,{name:`headers`,children:`Additional HTTP headers to send with each export request.`})]}}),e(s,{}),e(l,{heading:"OTLP trace exporter using the `http/json` protocol. Compatible with the Edge runtime. Mirrors `OTLPHttpJsonTraceExporter` from `@vercel/otel`.",get children(){return e(u,{name:`config`,children:`Optional exporter configuration (url, headers).`})}}),r`
1
+ import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
2
+ import { Show, code, splitProps } from "@alloy-js/core";
3
+ import { FunctionDeclaration } from "@alloy-js/typescript";
4
+ import { usePowerlines } from "@powerlines/plugin-alloy/core";
5
+ import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
6
+ import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
7
+ import { TSDoc, TSDocParam } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
8
+ import defu from "defu";
9
+
10
+ //#region src/components/trace-builtin.tsx
11
+ /**
12
+ * Generates the trace module for the Powerlines project.
13
+ */
14
+ function TraceBuiltin(props) {
15
+ const [{ children, imports }, rest] = splitProps(props, ["children", "imports"]);
16
+ const context = usePowerlines();
17
+ return createComponent(BuiltinFile, mergeProps({
18
+ id: "trace",
19
+ description: "The runtime OpenTelemetry trace module provides registerOTel and getTracer helpers that mirror the @vercel/otel API."
20
+ }, rest, {
21
+ get imports() {
22
+ return defu({
23
+ "@opentelemetry/api": [
24
+ { name: "trace" },
25
+ { name: "diag" },
26
+ { name: "propagation" },
27
+ { name: "context" },
28
+ { name: "metrics" },
29
+ { name: "DiagConsoleLogger" },
30
+ { name: "DiagLogLevel" },
31
+ {
32
+ name: "ContextManager",
33
+ type: true
34
+ },
35
+ {
36
+ name: "TextMapPropagator",
37
+ type: true
38
+ },
39
+ {
40
+ name: "Attributes",
41
+ type: true
42
+ }
43
+ ],
44
+ "@opentelemetry/api-logs": [{ name: "logs" }],
45
+ "@opentelemetry/context-async-hooks": [{ name: "AsyncLocalStorageContextManager" }],
46
+ "@opentelemetry/core": [
47
+ { name: "CompositePropagator" },
48
+ {
49
+ name: "ExportResult",
50
+ type: true
51
+ },
52
+ { name: "W3CBaggagePropagator" },
53
+ { name: "W3CTraceContextPropagator" },
54
+ { name: "parseKeyPairsIntoRecord" }
55
+ ],
56
+ "@opentelemetry/instrumentation": [{ name: "registerInstrumentations" }, {
57
+ name: "Instrumentation",
58
+ type: true
59
+ }],
60
+ "@opentelemetry/resources": [
61
+ { name: "resourceFromAttributes" },
62
+ { name: "detectResources" },
63
+ { name: "envDetector" }
64
+ ],
65
+ "@opentelemetry/sdk-logs": [{ name: "LoggerProvider" }],
66
+ "@opentelemetry/sdk-metrics": [{ name: "MeterProvider" }],
67
+ "@opentelemetry/sdk-trace-base": [
68
+ { name: "BasicTracerProvider" },
69
+ { name: "BatchSpanProcessor" },
70
+ { name: "RandomIdGenerator" },
71
+ { name: "AlwaysOnSampler" },
72
+ { name: "AlwaysOffSampler" },
73
+ { name: "ParentBasedSampler" },
74
+ { name: "TraceIdRatioBasedSampler" },
75
+ {
76
+ name: "ReadableSpan",
77
+ type: true
78
+ },
79
+ {
80
+ name: "Sampler",
81
+ type: true
82
+ },
83
+ {
84
+ name: "SpanExporter",
85
+ type: true
86
+ },
87
+ {
88
+ name: "SpanProcessor",
89
+ type: true
90
+ }
91
+ ],
92
+ "@powerlines/plugin-open-telemetry": [{
93
+ name: "Configuration",
94
+ type: true
95
+ }],
96
+ "@opentelemetry/exporter-trace-otlp-http": [{ name: "OTLPTraceExporter" }]
97
+ }, imports ?? {});
98
+ },
99
+ builtinImports: { env: ["env"] },
100
+ get children() {
101
+ return [
102
+ createComponent(TSDoc, {
103
+ heading: "Configuration for the OTLP HTTP trace exporters.",
104
+ get children() {
105
+ return [createComponent(TSDocParam, {
106
+ name: "url",
107
+ children: `The URL of the OTLP collector endpoint. Defaults to http://localhost:4318/v1/traces.`
108
+ }), createComponent(TSDocParam, {
109
+ name: "headers",
110
+ children: `Additional HTTP headers to send with each export request.`
111
+ })];
112
+ }
113
+ }),
114
+ createComponent(Spacing, {}),
115
+ createComponent(TSDoc, {
116
+ heading: "OTLP trace exporter using the `http/json` protocol. Compatible with the Edge runtime. Mirrors `OTLPHttpJsonTraceExporter` from `@vercel/otel`.",
117
+ get children() {
118
+ return createComponent(TSDocParam, {
119
+ name: "config",
120
+ children: `Optional exporter configuration (url, headers).`
121
+ });
122
+ }
123
+ }),
124
+ code`
2
125
  export class OTLPHttpJsonTraceExporter implements SpanExporter {
3
126
  private readonly impl: OTLPTraceExporter;
4
127
 
@@ -20,7 +143,18 @@ export class OTLPHttpJsonTraceExporter implements SpanExporter {
20
143
  forceFlush(): Promise<void> {
21
144
  return this.impl.forceFlush?.() ?? Promise.resolve();
22
145
  }
23
- }`,e(s,{}),e(l,{heading:"OTLP trace exporter using the `http/protobuf` protocol. Compatible with the Edge runtime. Mirrors `OTLPHttpProtoTraceExporter` from `@vercel/otel`.",get children(){return e(u,{name:`config`,children:`Optional exporter configuration (url, headers). The OTLP collector must support the protobuf encoding.`})}}),r`
146
+ }`,
147
+ createComponent(Spacing, {}),
148
+ createComponent(TSDoc, {
149
+ heading: "OTLP trace exporter using the `http/protobuf` protocol. Compatible with the Edge runtime. Mirrors `OTLPHttpProtoTraceExporter` from `@vercel/otel`.",
150
+ get children() {
151
+ return createComponent(TSDocParam, {
152
+ name: "config",
153
+ children: `Optional exporter configuration (url, headers). The OTLP collector must support the protobuf encoding.`
154
+ });
155
+ }
156
+ }),
157
+ code`
24
158
  export class OTLPHttpProtoTraceExporter implements SpanExporter {
25
159
  private readonly impl: OTLPTraceExporter;
26
160
 
@@ -45,7 +179,58 @@ export class OTLPHttpProtoTraceExporter implements SpanExporter {
45
179
  forceFlush(): Promise<void> {
46
180
  return this.impl.forceFlush?.() ?? Promise.resolve();
47
181
  }
48
- }`,e(s,{}),e(l,{heading:"OpenTelemetry SDK configuration. Mirrors the `@vercel/otel` `Configuration` interface.",get children(){return[e(u,{name:`serviceName`,children:`The name of your service. Can be overridden by the OTEL_SERVICE_NAME environment variable.`}),e(u,{name:`attributes`,children:`Additional resource attributes to apply to all spans.`}),e(u,{name:`propagators`,children:`Propagators for extending inbound and outbound contexts. Defaults to W3C Trace Context + Baggage.`}),e(u,{name:`traceSampler`,children:`Sampler to decide which requests to trace. Defaults to "always_on".`}),e(u,{name:`spanProcessors`,children:`Span processors to use. Defaults to "auto" which auto-configures based on environment variables.`}),e(u,{name:`traceExporter`,children:`Custom trace exporter. Defaults to "auto" which selects the best exporter for the environment.`})]}}),e(l,{heading:"Registers the OpenTelemetry SDK with the specified service name or configuration object. Should be called in `instrumentation.ts` before any other code.",get children(){return e(u,{name:`optionsOrServiceName`,children:`Either a service name string or a full Configuration object.`})}}),e(a,{name:`registerOTel`,export:!0,parameters:[{name:`optionsOrServiceName?`,type:`Configuration | string`}],returnType:`void`,get children(){return r`
182
+ }`,
183
+ createComponent(Spacing, {}),
184
+ createComponent(TSDoc, {
185
+ heading: "OpenTelemetry SDK configuration. Mirrors the `@vercel/otel` `Configuration` interface.",
186
+ get children() {
187
+ return [
188
+ createComponent(TSDocParam, {
189
+ name: "serviceName",
190
+ children: `The name of your service. Can be overridden by the OTEL_SERVICE_NAME environment variable.`
191
+ }),
192
+ createComponent(TSDocParam, {
193
+ name: "attributes",
194
+ children: `Additional resource attributes to apply to all spans.`
195
+ }),
196
+ createComponent(TSDocParam, {
197
+ name: "propagators",
198
+ children: `Propagators for extending inbound and outbound contexts. Defaults to W3C Trace Context + Baggage.`
199
+ }),
200
+ createComponent(TSDocParam, {
201
+ name: "traceSampler",
202
+ children: `Sampler to decide which requests to trace. Defaults to "always_on".`
203
+ }),
204
+ createComponent(TSDocParam, {
205
+ name: "spanProcessors",
206
+ children: `Span processors to use. Defaults to "auto" which auto-configures based on environment variables.`
207
+ }),
208
+ createComponent(TSDocParam, {
209
+ name: "traceExporter",
210
+ children: `Custom trace exporter. Defaults to "auto" which selects the best exporter for the environment.`
211
+ })
212
+ ];
213
+ }
214
+ }),
215
+ createComponent(TSDoc, {
216
+ heading: "Registers the OpenTelemetry SDK with the specified service name or configuration object. Should be called in `instrumentation.ts` before any other code.",
217
+ get children() {
218
+ return createComponent(TSDocParam, {
219
+ name: "optionsOrServiceName",
220
+ children: `Either a service name string or a full Configuration object.`
221
+ });
222
+ }
223
+ }),
224
+ createComponent(FunctionDeclaration, {
225
+ name: "registerOTel",
226
+ "export": true,
227
+ parameters: [{
228
+ name: "optionsOrServiceName?",
229
+ type: "Configuration | string"
230
+ }],
231
+ returnType: "void",
232
+ get children() {
233
+ return code`
49
234
  let options: Configuration;
50
235
  if (!optionsOrServiceName) {
51
236
  options = {};
@@ -84,7 +269,7 @@ export class OTLPHttpProtoTraceExporter implements SpanExporter {
84
269
  }
85
270
 
86
271
  const idGenerator = options.idGenerator ?? new RandomIdGenerator();
87
- const serviceName = env.OTEL_SERVICE_NAME || options.serviceName || "${g.config.name}";
272
+ const serviceName = env.OTEL_SERVICE_NAME || options.serviceName || "${context.config.name}";
88
273
 
89
274
  const contextManager: ContextManager =
90
275
  options.contextManager ?? new AsyncLocalStorageContextManager();
@@ -227,5 +412,48 @@ export class OTLPHttpProtoTraceExporter implements SpanExporter {
227
412
  );
228
413
  registerInstrumentations({ instrumentations });
229
414
 
230
- diag.info("@powerlines/plugin-open-telemetry: started", serviceName, env.RUNTIME);`}}),e(s,{}),e(l,{heading:"Returns a named tracer from the global OpenTelemetry TracerProvider. Wraps `trace.getTracer()` for convenience.",get children(){return[e(u,{name:`name`,children:`The name of the tracer (typically the instrumentation library name or component name).`}),e(u,{name:`version`,children:`Optional version of the instrumentation library.`})]}}),e(a,{name:`getTracer`,export:!0,parameters:[{name:`name`,type:`string`},{name:`version`,type:`string`,optional:!0}],returnType:`ReturnType<typeof trace.getTracer>`,children:r`return trace.getTracer(name, version);`}),e(s,{}),e(n,{get when(){return!!p},children:p})]}}))}export{f as TraceBuiltin};
415
+ diag.info("@powerlines/plugin-open-telemetry: started", serviceName, env.RUNTIME);`;
416
+ }
417
+ }),
418
+ createComponent(Spacing, {}),
419
+ createComponent(TSDoc, {
420
+ heading: "Returns a named tracer from the global OpenTelemetry TracerProvider. Wraps `trace.getTracer()` for convenience.",
421
+ get children() {
422
+ return [createComponent(TSDocParam, {
423
+ name: "name",
424
+ children: `The name of the tracer (typically the instrumentation library name or component name).`
425
+ }), createComponent(TSDocParam, {
426
+ name: "version",
427
+ children: `Optional version of the instrumentation library.`
428
+ })];
429
+ }
430
+ }),
431
+ createComponent(FunctionDeclaration, {
432
+ name: "getTracer",
433
+ "export": true,
434
+ parameters: [{
435
+ name: "name",
436
+ type: "string"
437
+ }, {
438
+ name: "version",
439
+ type: "string",
440
+ optional: true
441
+ }],
442
+ returnType: "ReturnType<typeof trace.getTracer>",
443
+ children: code`return trace.getTracer(name, version);`
444
+ }),
445
+ createComponent(Spacing, {}),
446
+ createComponent(Show, {
447
+ get when() {
448
+ return Boolean(children);
449
+ },
450
+ children
451
+ })
452
+ ];
453
+ }
454
+ }));
455
+ }
456
+
457
+ //#endregion
458
+ export { TraceBuiltin };
231
459
  //# sourceMappingURL=trace-builtin.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"trace-builtin.mjs","names":[],"sources":["../../src/components/trace-builtin.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 { code, Show, splitProps } from \"@alloy-js/core\";\nimport { FunctionDeclaration } from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport {\n BuiltinFile,\n BuiltinFileProps\n} from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport {\n TSDoc,\n TSDocParam\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport defu from \"defu\";\nimport { OpenTelemetryPluginContext } from \"../types\";\n\nexport type TraceBuiltinProps = Omit<BuiltinFileProps, \"id\">;\n\n/**\n * Generates the trace module for the Powerlines project.\n */\nexport function TraceBuiltin(props: TraceBuiltinProps) {\n const [{ children, imports }, rest] = splitProps(props, [\n \"children\",\n \"imports\"\n ]);\n\n const context = usePowerlines<OpenTelemetryPluginContext>();\n\n return (\n <BuiltinFile\n id=\"trace\"\n description=\"The runtime OpenTelemetry trace module provides registerOTel and getTracer helpers that mirror the @vercel/otel API.\"\n {...rest}\n imports={defu(\n {\n \"@opentelemetry/api\": [\n { name: \"trace\" },\n { name: \"diag\" },\n { name: \"propagation\" },\n { name: \"context\" },\n { name: \"metrics\" },\n { name: \"DiagConsoleLogger\" },\n { name: \"DiagLogLevel\" },\n { name: \"ContextManager\", type: true },\n { name: \"TextMapPropagator\", type: true },\n { name: \"Attributes\", type: true }\n ],\n \"@opentelemetry/api-logs\": [{ name: \"logs\" }],\n \"@opentelemetry/context-async-hooks\": [\n { name: \"AsyncLocalStorageContextManager\" }\n ],\n \"@opentelemetry/core\": [\n { name: \"CompositePropagator\" },\n { name: \"ExportResult\", type: true },\n { name: \"W3CBaggagePropagator\" },\n { name: \"W3CTraceContextPropagator\" },\n { name: \"parseKeyPairsIntoRecord\" }\n ],\n \"@opentelemetry/instrumentation\": [\n { name: \"registerInstrumentations\" },\n { name: \"Instrumentation\", type: true }\n ],\n \"@opentelemetry/resources\": [\n { name: \"resourceFromAttributes\" },\n { name: \"detectResources\" },\n { name: \"envDetector\" }\n ],\n \"@opentelemetry/sdk-logs\": [{ name: \"LoggerProvider\" }],\n \"@opentelemetry/sdk-metrics\": [{ name: \"MeterProvider\" }],\n \"@opentelemetry/sdk-trace-base\": [\n { name: \"BasicTracerProvider\" },\n { name: \"BatchSpanProcessor\" },\n { name: \"RandomIdGenerator\" },\n { name: \"AlwaysOnSampler\" },\n { name: \"AlwaysOffSampler\" },\n { name: \"ParentBasedSampler\" },\n { name: \"TraceIdRatioBasedSampler\" },\n { name: \"ReadableSpan\", type: true },\n { name: \"Sampler\", type: true },\n { name: \"SpanExporter\", type: true },\n { name: \"SpanProcessor\", type: true }\n ],\n \"@powerlines/plugin-open-telemetry\": [\n { name: \"Configuration\", type: true }\n ],\n \"@opentelemetry/exporter-trace-otlp-http\": [\n { name: \"OTLPTraceExporter\" }\n ]\n },\n imports ?? {}\n )}\n builtinImports={{\n env: [\"env\"]\n }}>\n <TSDoc heading=\"Configuration for the OTLP HTTP trace exporters.\">\n <TSDocParam name=\"url\">\n {`The URL of the OTLP collector endpoint. Defaults to http://localhost:4318/v1/traces.`}\n </TSDocParam>\n <TSDocParam name=\"headers\">\n {`Additional HTTP headers to send with each export request.`}\n </TSDocParam>\n </TSDoc>\n <Spacing />\n <TSDoc heading=\"OTLP trace exporter using the `http/json` protocol. Compatible with the Edge runtime. Mirrors `OTLPHttpJsonTraceExporter` from `@vercel/otel`.\">\n <TSDocParam name=\"config\">\n {`Optional exporter configuration (url, headers).`}\n </TSDocParam>\n </TSDoc>\n {code`\nexport class OTLPHttpJsonTraceExporter implements SpanExporter {\n private readonly impl: OTLPTraceExporter;\n\n constructor(config: OTLPExporterConfig = {}) {\n this.impl = new OTLPTraceExporter({\n url: config.url ?? (env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT ?? \"http://localhost:4318/v1/traces\"),\n headers: (config.headers as Record<string, string>) ?? {},\n });\n }\n\n export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void {\n this.impl.export(spans, resultCallback);\n }\n\n shutdown(): Promise<void> {\n return this.impl.shutdown();\n }\n\n forceFlush(): Promise<void> {\n return this.impl.forceFlush?.() ?? Promise.resolve();\n }\n}`}\n <Spacing />\n <TSDoc heading=\"OTLP trace exporter using the `http/protobuf` protocol. Compatible with the Edge runtime. Mirrors `OTLPHttpProtoTraceExporter` from `@vercel/otel`.\">\n <TSDocParam name=\"config\">\n {`Optional exporter configuration (url, headers). The OTLP collector must support the protobuf encoding.`}\n </TSDocParam>\n </TSDoc>\n {code`\nexport class OTLPHttpProtoTraceExporter implements SpanExporter {\n private readonly impl: OTLPTraceExporter;\n\n constructor(config: OTLPExporterConfig = {}) {\n this.impl = new OTLPTraceExporter({\n url: config.url ?? env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,\n headers: {\n \"Content-Type\": \"application/x-protobuf\",\n ...((config.headers as Record<string, string>) ?? {}),\n },\n });\n }\n\n export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void {\n this.impl.export(spans, resultCallback);\n }\n\n shutdown(): Promise<void> {\n return this.impl.shutdown();\n }\n\n forceFlush(): Promise<void> {\n return this.impl.forceFlush?.() ?? Promise.resolve();\n }\n}`}\n <Spacing />\n\n <TSDoc heading=\"OpenTelemetry SDK configuration. Mirrors the `@vercel/otel` `Configuration` interface.\">\n <TSDocParam name=\"serviceName\">\n {`The name of your service. Can be overridden by the OTEL_SERVICE_NAME environment variable.`}\n </TSDocParam>\n <TSDocParam name=\"attributes\">\n {`Additional resource attributes to apply to all spans.`}\n </TSDocParam>\n <TSDocParam name=\"propagators\">\n {`Propagators for extending inbound and outbound contexts. Defaults to W3C Trace Context + Baggage.`}\n </TSDocParam>\n <TSDocParam name=\"traceSampler\">\n {`Sampler to decide which requests to trace. Defaults to \"always_on\".`}\n </TSDocParam>\n <TSDocParam name=\"spanProcessors\">\n {`Span processors to use. Defaults to \"auto\" which auto-configures based on environment variables.`}\n </TSDocParam>\n <TSDocParam name=\"traceExporter\">\n {`Custom trace exporter. Defaults to \"auto\" which selects the best exporter for the environment.`}\n </TSDocParam>\n </TSDoc>\n <TSDoc heading=\"Registers the OpenTelemetry SDK with the specified service name or configuration object. Should be called in `instrumentation.ts` before any other code.\">\n <TSDocParam name=\"optionsOrServiceName\">\n {`Either a service name string or a full Configuration object.`}\n </TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n name=\"registerOTel\"\n export\n parameters={[\n {\n name: \"optionsOrServiceName?\",\n type: \"Configuration | string\"\n }\n ]}\n returnType=\"void\">\n {code`\n let options: Configuration;\n if (!optionsOrServiceName) {\n options = {};\n } else if (typeof optionsOrServiceName === \"string\") {\n options = { serviceName: optionsOrServiceName };\n } else {\n options = optionsOrServiceName;\n }\n\n if (env.OTEL_SDK_DISABLED) {\n return;\n }\n\n // Optional diagnostic logging via OTEL_LOG_LEVEL.\n if (env.OTEL_LOG_LEVEL || env.LOG_LEVEL !== undefined) {\n const logLevelMap: Record<string, DiagLogLevel> = {\n ALL: DiagLogLevel.ALL,\n VERBOSE: DiagLogLevel.VERBOSE,\n DEBUG: DiagLogLevel.DEBUG,\n INFO: DiagLogLevel.INFO,\n WARN: DiagLogLevel.WARN,\n ERROR: DiagLogLevel.ERROR,\n NONE: DiagLogLevel.NONE,\n };\n\n let level: DiagLogLevel | undefined = undefined;\n if (env.OTEL_LOG_LEVEL) {\n level = logLevelMap[env.OTEL_LOG_LEVEL.toUpperCase()];\n } else if (env.LOG_LEVEL !== undefined) {\n level = env.LOG_LEVEL === null ? DiagLogLevel.NONE : logLevelMap[env.LOG_LEVEL.toUpperCase()];\n }\n\n if (level !== undefined) {\n diag.setLogger(new DiagConsoleLogger(), { logLevel: level });\n }\n }\n\n const idGenerator = options.idGenerator ?? new RandomIdGenerator();\n const serviceName = env.OTEL_SERVICE_NAME || options.serviceName || \"${context.config.name}\";\n\n const contextManager: ContextManager =\n options.contextManager ?? new AsyncLocalStorageContextManager();\n contextManager.enable();\n context.setGlobalContextManager(contextManager);\n\n let resource = resourceFromAttributes({\n \"service.name\": serviceName,\n \"process.runtime.name\": env.RUNTIME,\n ...(options.attributes ?? {}),\n });\n\n const autoDetectResources = options.autoDetectResources ?? true;\n if (autoDetectResources) {\n const detectedResource = detectResources({\n detectors: options.resourceDetectors ?? [envDetector],\n });\n resource = resource.merge(detectedResource);\n }\n\n const envPropagators = process.env.OTEL_PROPAGATORS\n ? process.env.OTEL_PROPAGATORS.split(\",\").map((s) => s.trim())\n : undefined;\n const propagatorArgs: Array<TextMapPropagator | string> =\n options.propagators ?? envPropagators ?? [\"auto\"];\n const resolvedPropagators: TextMapPropagator[] = propagatorArgs\n .flatMap((p) => {\n if (p === \"none\") return [];\n if (p === \"auto\" || p === \"tracecontext\") {\n const list: TextMapPropagator[] = [new W3CTraceContextPropagator()];\n if (p === \"auto\") list.push(new W3CBaggagePropagator());\n return list;\n }\n if (p === \"baggage\") return [new W3CBaggagePropagator()];\n if (typeof p !== \"string\") return [p as TextMapPropagator];\n throw new Error(\\`@powerlines/plugin-open-telemetry: Unknown propagator \"\\${p}\"\\`);\n });\n propagation.setGlobalPropagator(\n new CompositePropagator({ propagators: resolvedPropagators })\n );\n\n const samplerName = !options.traceSampler || options.traceSampler === \"auto\"\n ? env.OTEL_TRACES_SAMPLER\n : typeof options.traceSampler === \"string\"\n ? options.traceSampler\n : undefined;\n\n let sampler: Sampler;\n if (options.traceSampler && typeof options.traceSampler !== \"string\") {\n sampler = options.traceSampler as Sampler;\n } else {\n const probability = isNaN(env.OTEL_TRACES_SAMPLER_ARG) || env.OTEL_TRACES_SAMPLER_ARG < 0 || env.OTEL_TRACES_SAMPLER_ARG > 1 ? 1 : env.OTEL_TRACES_SAMPLER_ARG;\n switch (samplerName) {\n case \"always_off\":\n sampler = new AlwaysOffSampler();\n break;\n case \"parentbased_always_on\":\n sampler = new ParentBasedSampler({ root: new AlwaysOnSampler() });\n break;\n case \"parentbased_always_off\":\n sampler = new ParentBasedSampler({ root: new AlwaysOffSampler() });\n break;\n case \"traceidratio\":\n sampler = new TraceIdRatioBasedSampler(probability);\n break;\n case \"parentbased_traceidratio\":\n sampler = new ParentBasedSampler({\n root: new TraceIdRatioBasedSampler(probability),\n });\n break;\n case \"always_on\":\n default:\n sampler = new AlwaysOnSampler();\n }\n }\n\n const spanProcessors: SpanProcessor[] = (options.spanProcessors ?? [\"auto\"]).flatMap((sp) => {\n if (sp !== \"auto\") {\n return [sp as SpanProcessor];\n }\n\n const processors: SpanProcessor[] = [];\n if (\n !options.traceExporter ||\n options.traceExporter === \"auto\" ||\n env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT\n ) {\n // Dynamic import keeps the exporter optional at runtime.\n diag.debug(\n \"@powerlines/plugin-open-telemetry: Auto-configuring OTLP trace exporter\",\n env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT\n );\n }\n return processors;\n });\n\n // If a custom traceExporter was provided, wrap it in a BatchSpanProcessor.\n if (options.traceExporter && options.traceExporter !== \"auto\") {\n spanProcessors.push(\n new BatchSpanProcessor(options.traceExporter as SpanExporter)\n );\n }\n\n const tracerProvider = new BasicTracerProvider({\n resource,\n idGenerator,\n sampler,\n spanLimits: options.spanLimits,\n spanProcessors,\n });\n trace.setGlobalTracerProvider(tracerProvider);\n\n if (options.logRecordProcessors) {\n const loggerProvider = new LoggerProvider({\n resource,\n processors: options.logRecordProcessors,\n });\n logs.setGlobalLoggerProvider(loggerProvider);\n }\n\n if (options.metricReaders || options.views) {\n const meterProvider = new MeterProvider({\n resource,\n views: options.views ?? [],\n readers: options.metricReaders ?? [],\n });\n metrics.setGlobalMeterProvider(meterProvider);\n }\n\n const instrumentationArgs: Array<Instrumentation | string> = options.instrumentations ?? [\"auto\"];\n const instrumentations: Instrumentation[] = instrumentationArgs.flatMap(\n (inst) => {\n if (typeof inst !== \"string\") {\n return [inst as Instrumentation];\n }\n\n // \"auto\" and \"fetch\" are resolved by the consumer via their own imports.\n return [];\n }\n );\n registerInstrumentations({ instrumentations });\n\n diag.info(\"@powerlines/plugin-open-telemetry: started\", serviceName, env.RUNTIME);`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"Returns a named tracer from the global OpenTelemetry TracerProvider. Wraps `trace.getTracer()` for convenience.\">\n <TSDocParam name=\"name\">\n {`The name of the tracer (typically the instrumentation library name or component name).`}\n </TSDocParam>\n <TSDocParam name=\"version\">\n {`Optional version of the instrumentation library.`}\n </TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n name=\"getTracer\"\n export\n parameters={[\n { name: \"name\", type: \"string\" },\n { name: \"version\", type: \"string\", optional: true }\n ]}\n returnType=\"ReturnType<typeof trace.getTracer>\">\n {code`return trace.getTracer(name, version);`}\n </FunctionDeclaration>\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"trace-builtin.mjs","names":[],"sources":["../../src/components/trace-builtin.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 { code, Show, splitProps } from \"@alloy-js/core\";\nimport { FunctionDeclaration } from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport {\n BuiltinFile,\n BuiltinFileProps\n} from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport {\n TSDoc,\n TSDocParam\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport defu from \"defu\";\nimport { OpenTelemetryPluginContext } from \"../types\";\n\nexport type TraceBuiltinProps = Omit<BuiltinFileProps, \"id\">;\n\n/**\n * Generates the trace module for the Powerlines project.\n */\nexport function TraceBuiltin(props: TraceBuiltinProps) {\n const [{ children, imports }, rest] = splitProps(props, [\n \"children\",\n \"imports\"\n ]);\n\n const context = usePowerlines<OpenTelemetryPluginContext>();\n\n return (\n <BuiltinFile\n id=\"trace\"\n description=\"The runtime OpenTelemetry trace module provides registerOTel and getTracer helpers that mirror the @vercel/otel API.\"\n {...rest}\n imports={defu(\n {\n \"@opentelemetry/api\": [\n { name: \"trace\" },\n { name: \"diag\" },\n { name: \"propagation\" },\n { name: \"context\" },\n { name: \"metrics\" },\n { name: \"DiagConsoleLogger\" },\n { name: \"DiagLogLevel\" },\n { name: \"ContextManager\", type: true },\n { name: \"TextMapPropagator\", type: true },\n { name: \"Attributes\", type: true }\n ],\n \"@opentelemetry/api-logs\": [{ name: \"logs\" }],\n \"@opentelemetry/context-async-hooks\": [\n { name: \"AsyncLocalStorageContextManager\" }\n ],\n \"@opentelemetry/core\": [\n { name: \"CompositePropagator\" },\n { name: \"ExportResult\", type: true },\n { name: \"W3CBaggagePropagator\" },\n { name: \"W3CTraceContextPropagator\" },\n { name: \"parseKeyPairsIntoRecord\" }\n ],\n \"@opentelemetry/instrumentation\": [\n { name: \"registerInstrumentations\" },\n { name: \"Instrumentation\", type: true }\n ],\n \"@opentelemetry/resources\": [\n { name: \"resourceFromAttributes\" },\n { name: \"detectResources\" },\n { name: \"envDetector\" }\n ],\n \"@opentelemetry/sdk-logs\": [{ name: \"LoggerProvider\" }],\n \"@opentelemetry/sdk-metrics\": [{ name: \"MeterProvider\" }],\n \"@opentelemetry/sdk-trace-base\": [\n { name: \"BasicTracerProvider\" },\n { name: \"BatchSpanProcessor\" },\n { name: \"RandomIdGenerator\" },\n { name: \"AlwaysOnSampler\" },\n { name: \"AlwaysOffSampler\" },\n { name: \"ParentBasedSampler\" },\n { name: \"TraceIdRatioBasedSampler\" },\n { name: \"ReadableSpan\", type: true },\n { name: \"Sampler\", type: true },\n { name: \"SpanExporter\", type: true },\n { name: \"SpanProcessor\", type: true }\n ],\n \"@powerlines/plugin-open-telemetry\": [\n { name: \"Configuration\", type: true }\n ],\n \"@opentelemetry/exporter-trace-otlp-http\": [\n { name: \"OTLPTraceExporter\" }\n ]\n },\n imports ?? {}\n )}\n builtinImports={{\n env: [\"env\"]\n }}>\n <TSDoc heading=\"Configuration for the OTLP HTTP trace exporters.\">\n <TSDocParam name=\"url\">\n {`The URL of the OTLP collector endpoint. Defaults to http://localhost:4318/v1/traces.`}\n </TSDocParam>\n <TSDocParam name=\"headers\">\n {`Additional HTTP headers to send with each export request.`}\n </TSDocParam>\n </TSDoc>\n <Spacing />\n <TSDoc heading=\"OTLP trace exporter using the `http/json` protocol. Compatible with the Edge runtime. Mirrors `OTLPHttpJsonTraceExporter` from `@vercel/otel`.\">\n <TSDocParam name=\"config\">\n {`Optional exporter configuration (url, headers).`}\n </TSDocParam>\n </TSDoc>\n {code`\nexport class OTLPHttpJsonTraceExporter implements SpanExporter {\n private readonly impl: OTLPTraceExporter;\n\n constructor(config: OTLPExporterConfig = {}) {\n this.impl = new OTLPTraceExporter({\n url: config.url ?? (env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT ?? \"http://localhost:4318/v1/traces\"),\n headers: (config.headers as Record<string, string>) ?? {},\n });\n }\n\n export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void {\n this.impl.export(spans, resultCallback);\n }\n\n shutdown(): Promise<void> {\n return this.impl.shutdown();\n }\n\n forceFlush(): Promise<void> {\n return this.impl.forceFlush?.() ?? Promise.resolve();\n }\n}`}\n <Spacing />\n <TSDoc heading=\"OTLP trace exporter using the `http/protobuf` protocol. Compatible with the Edge runtime. Mirrors `OTLPHttpProtoTraceExporter` from `@vercel/otel`.\">\n <TSDocParam name=\"config\">\n {`Optional exporter configuration (url, headers). The OTLP collector must support the protobuf encoding.`}\n </TSDocParam>\n </TSDoc>\n {code`\nexport class OTLPHttpProtoTraceExporter implements SpanExporter {\n private readonly impl: OTLPTraceExporter;\n\n constructor(config: OTLPExporterConfig = {}) {\n this.impl = new OTLPTraceExporter({\n url: config.url ?? env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,\n headers: {\n \"Content-Type\": \"application/x-protobuf\",\n ...((config.headers as Record<string, string>) ?? {}),\n },\n });\n }\n\n export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void {\n this.impl.export(spans, resultCallback);\n }\n\n shutdown(): Promise<void> {\n return this.impl.shutdown();\n }\n\n forceFlush(): Promise<void> {\n return this.impl.forceFlush?.() ?? Promise.resolve();\n }\n}`}\n <Spacing />\n\n <TSDoc heading=\"OpenTelemetry SDK configuration. Mirrors the `@vercel/otel` `Configuration` interface.\">\n <TSDocParam name=\"serviceName\">\n {`The name of your service. Can be overridden by the OTEL_SERVICE_NAME environment variable.`}\n </TSDocParam>\n <TSDocParam name=\"attributes\">\n {`Additional resource attributes to apply to all spans.`}\n </TSDocParam>\n <TSDocParam name=\"propagators\">\n {`Propagators for extending inbound and outbound contexts. Defaults to W3C Trace Context + Baggage.`}\n </TSDocParam>\n <TSDocParam name=\"traceSampler\">\n {`Sampler to decide which requests to trace. Defaults to \"always_on\".`}\n </TSDocParam>\n <TSDocParam name=\"spanProcessors\">\n {`Span processors to use. Defaults to \"auto\" which auto-configures based on environment variables.`}\n </TSDocParam>\n <TSDocParam name=\"traceExporter\">\n {`Custom trace exporter. Defaults to \"auto\" which selects the best exporter for the environment.`}\n </TSDocParam>\n </TSDoc>\n <TSDoc heading=\"Registers the OpenTelemetry SDK with the specified service name or configuration object. Should be called in `instrumentation.ts` before any other code.\">\n <TSDocParam name=\"optionsOrServiceName\">\n {`Either a service name string or a full Configuration object.`}\n </TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n name=\"registerOTel\"\n export\n parameters={[\n {\n name: \"optionsOrServiceName?\",\n type: \"Configuration | string\"\n }\n ]}\n returnType=\"void\">\n {code`\n let options: Configuration;\n if (!optionsOrServiceName) {\n options = {};\n } else if (typeof optionsOrServiceName === \"string\") {\n options = { serviceName: optionsOrServiceName };\n } else {\n options = optionsOrServiceName;\n }\n\n if (env.OTEL_SDK_DISABLED) {\n return;\n }\n\n // Optional diagnostic logging via OTEL_LOG_LEVEL.\n if (env.OTEL_LOG_LEVEL || env.LOG_LEVEL !== undefined) {\n const logLevelMap: Record<string, DiagLogLevel> = {\n ALL: DiagLogLevel.ALL,\n VERBOSE: DiagLogLevel.VERBOSE,\n DEBUG: DiagLogLevel.DEBUG,\n INFO: DiagLogLevel.INFO,\n WARN: DiagLogLevel.WARN,\n ERROR: DiagLogLevel.ERROR,\n NONE: DiagLogLevel.NONE,\n };\n\n let level: DiagLogLevel | undefined = undefined;\n if (env.OTEL_LOG_LEVEL) {\n level = logLevelMap[env.OTEL_LOG_LEVEL.toUpperCase()];\n } else if (env.LOG_LEVEL !== undefined) {\n level = env.LOG_LEVEL === null ? DiagLogLevel.NONE : logLevelMap[env.LOG_LEVEL.toUpperCase()];\n }\n\n if (level !== undefined) {\n diag.setLogger(new DiagConsoleLogger(), { logLevel: level });\n }\n }\n\n const idGenerator = options.idGenerator ?? new RandomIdGenerator();\n const serviceName = env.OTEL_SERVICE_NAME || options.serviceName || \"${context.config.name}\";\n\n const contextManager: ContextManager =\n options.contextManager ?? new AsyncLocalStorageContextManager();\n contextManager.enable();\n context.setGlobalContextManager(contextManager);\n\n let resource = resourceFromAttributes({\n \"service.name\": serviceName,\n \"process.runtime.name\": env.RUNTIME,\n ...(options.attributes ?? {}),\n });\n\n const autoDetectResources = options.autoDetectResources ?? true;\n if (autoDetectResources) {\n const detectedResource = detectResources({\n detectors: options.resourceDetectors ?? [envDetector],\n });\n resource = resource.merge(detectedResource);\n }\n\n const envPropagators = process.env.OTEL_PROPAGATORS\n ? process.env.OTEL_PROPAGATORS.split(\",\").map((s) => s.trim())\n : undefined;\n const propagatorArgs: Array<TextMapPropagator | string> =\n options.propagators ?? envPropagators ?? [\"auto\"];\n const resolvedPropagators: TextMapPropagator[] = propagatorArgs\n .flatMap((p) => {\n if (p === \"none\") return [];\n if (p === \"auto\" || p === \"tracecontext\") {\n const list: TextMapPropagator[] = [new W3CTraceContextPropagator()];\n if (p === \"auto\") list.push(new W3CBaggagePropagator());\n return list;\n }\n if (p === \"baggage\") return [new W3CBaggagePropagator()];\n if (typeof p !== \"string\") return [p as TextMapPropagator];\n throw new Error(\\`@powerlines/plugin-open-telemetry: Unknown propagator \"\\${p}\"\\`);\n });\n propagation.setGlobalPropagator(\n new CompositePropagator({ propagators: resolvedPropagators })\n );\n\n const samplerName = !options.traceSampler || options.traceSampler === \"auto\"\n ? env.OTEL_TRACES_SAMPLER\n : typeof options.traceSampler === \"string\"\n ? options.traceSampler\n : undefined;\n\n let sampler: Sampler;\n if (options.traceSampler && typeof options.traceSampler !== \"string\") {\n sampler = options.traceSampler as Sampler;\n } else {\n const probability = isNaN(env.OTEL_TRACES_SAMPLER_ARG) || env.OTEL_TRACES_SAMPLER_ARG < 0 || env.OTEL_TRACES_SAMPLER_ARG > 1 ? 1 : env.OTEL_TRACES_SAMPLER_ARG;\n switch (samplerName) {\n case \"always_off\":\n sampler = new AlwaysOffSampler();\n break;\n case \"parentbased_always_on\":\n sampler = new ParentBasedSampler({ root: new AlwaysOnSampler() });\n break;\n case \"parentbased_always_off\":\n sampler = new ParentBasedSampler({ root: new AlwaysOffSampler() });\n break;\n case \"traceidratio\":\n sampler = new TraceIdRatioBasedSampler(probability);\n break;\n case \"parentbased_traceidratio\":\n sampler = new ParentBasedSampler({\n root: new TraceIdRatioBasedSampler(probability),\n });\n break;\n case \"always_on\":\n default:\n sampler = new AlwaysOnSampler();\n }\n }\n\n const spanProcessors: SpanProcessor[] = (options.spanProcessors ?? [\"auto\"]).flatMap((sp) => {\n if (sp !== \"auto\") {\n return [sp as SpanProcessor];\n }\n\n const processors: SpanProcessor[] = [];\n if (\n !options.traceExporter ||\n options.traceExporter === \"auto\" ||\n env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT\n ) {\n // Dynamic import keeps the exporter optional at runtime.\n diag.debug(\n \"@powerlines/plugin-open-telemetry: Auto-configuring OTLP trace exporter\",\n env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT\n );\n }\n return processors;\n });\n\n // If a custom traceExporter was provided, wrap it in a BatchSpanProcessor.\n if (options.traceExporter && options.traceExporter !== \"auto\") {\n spanProcessors.push(\n new BatchSpanProcessor(options.traceExporter as SpanExporter)\n );\n }\n\n const tracerProvider = new BasicTracerProvider({\n resource,\n idGenerator,\n sampler,\n spanLimits: options.spanLimits,\n spanProcessors,\n });\n trace.setGlobalTracerProvider(tracerProvider);\n\n if (options.logRecordProcessors) {\n const loggerProvider = new LoggerProvider({\n resource,\n processors: options.logRecordProcessors,\n });\n logs.setGlobalLoggerProvider(loggerProvider);\n }\n\n if (options.metricReaders || options.views) {\n const meterProvider = new MeterProvider({\n resource,\n views: options.views ?? [],\n readers: options.metricReaders ?? [],\n });\n metrics.setGlobalMeterProvider(meterProvider);\n }\n\n const instrumentationArgs: Array<Instrumentation | string> = options.instrumentations ?? [\"auto\"];\n const instrumentations: Instrumentation[] = instrumentationArgs.flatMap(\n (inst) => {\n if (typeof inst !== \"string\") {\n return [inst as Instrumentation];\n }\n\n // \"auto\" and \"fetch\" are resolved by the consumer via their own imports.\n return [];\n }\n );\n registerInstrumentations({ instrumentations });\n\n diag.info(\"@powerlines/plugin-open-telemetry: started\", serviceName, env.RUNTIME);`}\n </FunctionDeclaration>\n <Spacing />\n <TSDoc heading=\"Returns a named tracer from the global OpenTelemetry TracerProvider. Wraps `trace.getTracer()` for convenience.\">\n <TSDocParam name=\"name\">\n {`The name of the tracer (typically the instrumentation library name or component name).`}\n </TSDocParam>\n <TSDocParam name=\"version\">\n {`Optional version of the instrumentation library.`}\n </TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n name=\"getTracer\"\n export\n parameters={[\n { name: \"name\", type: \"string\" },\n { name: \"version\", type: \"string\", optional: true }\n ]}\n returnType=\"ReturnType<typeof trace.getTracer>\">\n {code`return trace.getTracer(name, version);`}\n </FunctionDeclaration>\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":"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"}
@@ -1 +1,24 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@stryke/path/join-paths`),t=require(`automd`),n=require(`powerlines/plugin-utils`);const r=r=>(0,t.defineGenerator)({name:`trace`,async generate(){let t=(0,e.joinPaths)((0,n.getDocsOutputPath)(r.config.root),`trace.md`);return r.fs.existsSync(t)?{contents:await r.fs.read(t)||``}:{contents:``}}});exports.trace=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _stryke_path_join_paths = require("@stryke/path/join-paths");
4
+ let automd = require("automd");
5
+ let powerlines_plugin_utils = require("powerlines/plugin-utils");
6
+
7
+ //#region src/helpers/automd-generator.ts
8
+ /**
9
+ * AutoMD generator to generate feature flags documentation
10
+ *
11
+ * @param context - The generator context.
12
+ * @returns The generated documentation content.
13
+ */
14
+ const trace = (context) => (0, automd.defineGenerator)({
15
+ name: "trace",
16
+ async generate() {
17
+ const traceDocFile = (0, _stryke_path_join_paths.joinPaths)((0, powerlines_plugin_utils.getDocsOutputPath)(context.config.root), "trace.md");
18
+ if (!context.fs.existsSync(traceDocFile)) return { contents: "" };
19
+ return { contents: await context.fs.read(traceDocFile) || "" };
20
+ }
21
+ });
22
+
23
+ //#endregion
24
+ exports.trace = trace;
@@ -1,2 +1,23 @@
1
- import{joinPaths as e}from"@stryke/path/join-paths";import{defineGenerator as t}from"automd";import{getDocsOutputPath as n}from"powerlines/plugin-utils";const r=r=>t({name:`trace`,async generate(){let t=e(n(r.config.root),`trace.md`);return r.fs.existsSync(t)?{contents:await r.fs.read(t)||``}:{contents:``}}});export{r as trace};
1
+ import { joinPaths } from "@stryke/path/join-paths";
2
+ import { defineGenerator } from "automd";
3
+ import { getDocsOutputPath } from "powerlines/plugin-utils";
4
+
5
+ //#region src/helpers/automd-generator.ts
6
+ /**
7
+ * AutoMD generator to generate feature flags documentation
8
+ *
9
+ * @param context - The generator context.
10
+ * @returns The generated documentation content.
11
+ */
12
+ const trace = (context) => defineGenerator({
13
+ name: "trace",
14
+ async generate() {
15
+ const traceDocFile = joinPaths(getDocsOutputPath(context.config.root), "trace.md");
16
+ if (!context.fs.existsSync(traceDocFile)) return { contents: "" };
17
+ return { contents: await context.fs.read(traceDocFile) || "" };
18
+ }
19
+ });
20
+
21
+ //#endregion
22
+ export { trace };
2
23
  //# sourceMappingURL=automd-generator.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"automd-generator.mjs","names":[],"sources":["../../src/helpers/automd-generator.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 { joinPaths } from \"@stryke/path/join-paths\";\nimport { defineGenerator } from \"automd\";\nimport { UnresolvedContext } from \"powerlines\";\nimport { getDocsOutputPath } from \"powerlines/plugin-utils\";\n\n/**\n * AutoMD generator to generate feature flags documentation\n *\n * @param context - The generator context.\n * @returns The generated documentation content.\n */\nexport const trace = (context: UnresolvedContext) =>\n defineGenerator({\n name: \"trace\",\n async generate() {\n const traceDocFile = joinPaths(\n getDocsOutputPath(context.config.root),\n \"trace.md\"\n );\n\n if (!context.fs.existsSync(traceDocFile)) {\n return {\n contents: \"\"\n };\n }\n\n const contents = await context.fs.read(traceDocFile);\n\n return {\n contents: contents || \"\"\n };\n }\n });\n"],"mappings":"yJA6BA,MAAa,EAAQ,GAAU,EAAiB,CAC9C,KAAA,QACA,MAAM,UAAS,CACb,IAAM,EAAW,EAAA,EAAA,EAAA,OAAA,KAAA,CAAA,WAAA,CAOjB,OANE,EAAM,GAAA,WAAe,EAAS,CAM5B,CACF,SAAI,MAFY,EAAW,GAAA,KAAA,EAAe,EAE3B,GAChB,CAPG,CACA,SAAS,GACV"}
1
+ {"version":3,"file":"automd-generator.mjs","names":[],"sources":["../../src/helpers/automd-generator.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 { joinPaths } from \"@stryke/path/join-paths\";\nimport { defineGenerator } from \"automd\";\nimport { UnresolvedContext } from \"powerlines\";\nimport { getDocsOutputPath } from \"powerlines/plugin-utils\";\n\n/**\n * AutoMD generator to generate feature flags documentation\n *\n * @param context - The generator context.\n * @returns The generated documentation content.\n */\nexport const trace = (context: UnresolvedContext) =>\n defineGenerator({\n name: \"trace\",\n async generate() {\n const traceDocFile = joinPaths(\n getDocsOutputPath(context.config.root),\n \"trace.md\"\n );\n\n if (!context.fs.existsSync(traceDocFile)) {\n return {\n contents: \"\"\n };\n }\n\n const contents = await context.fs.read(traceDocFile);\n\n return {\n contents: contents || \"\"\n };\n }\n });\n"],"mappings":";;;;;;;;;;;AA6BA,MAAa,SAAQ,YAAU,gBAAiB;CAC9C,MAAA;CACA,MAAM,WAAS;EACb,MAAM,eAAW,UAAA,kBAAA,QAAA,OAAA,KAAA,EAAA,WAAA;AACjB,MAAE,CAAA,QAAM,GAAA,WAAe,aAAS,CAC9B,QAAE,EACA,UAAS,IACV;AAGH,SAAI,EACF,UAAI,MAFY,QAAW,GAAA,KAAA,aAAe,IAE3B,IAChB"}
@@ -1 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./automd-generator.cjs`);exports.trace=e.trace;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_helpers_automd_generator = require('./automd-generator.cjs');
3
+
4
+ exports.trace = require_helpers_automd_generator.trace;
@@ -1 +1,3 @@
1
- import{trace as e}from"./automd-generator.mjs";export{e as trace};
1
+ import { trace } from "./automd-generator.mjs";
2
+
3
+ export { trace };
package/dist/index.cjs CHANGED
@@ -1 +1,40 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./_virtual/_rolldown/runtime.cjs`),t=require(`./helpers/automd-generator.cjs`),n=require(`./components/trace-builtin.cjs`);let r=require(`@alloy-js/core/jsx-runtime`),i=require(`defu`);i=e.__toESM(i);let a=require(`@powerlines/plugin-alloy/render`),o=require(`@powerlines/plugin-automd`);o=e.__toESM(o);let s=require(`@powerlines/plugin-env`);s=e.__toESM(s);const c=(e={})=>[(0,s.default)(e.env),{name:`open-telemetry`,async prepare(){return this.debug(`Preparing the OpenTelemetry runtime artifacts for the Powerlines project.`),(0,a.render)(this,(0,r.createComponent)(n.TraceBuiltin,{}))}},{name:`open-telemetry:automd-generator`,config(){return{automd:(0,i.default)(e.automd??{},{generators:{trace:t.trace(this)}})}}},(0,o.default)(e.automd)];exports.default=c,exports.plugin=c;
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ const require_helpers_automd_generator = require('./helpers/automd-generator.cjs');
4
+ const require_components_trace_builtin = require('./components/trace-builtin.cjs');
5
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
6
+ let defu = require("defu");
7
+ defu = require_runtime.__toESM(defu);
8
+ let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
9
+ let _powerlines_plugin_automd = require("@powerlines/plugin-automd");
10
+ _powerlines_plugin_automd = require_runtime.__toESM(_powerlines_plugin_automd);
11
+ let _powerlines_plugin_env = require("@powerlines/plugin-env");
12
+ _powerlines_plugin_env = require_runtime.__toESM(_powerlines_plugin_env);
13
+
14
+ //#region src/index.tsx
15
+ /**
16
+ * A Powerlines plugin to inject environment variables into the source code.
17
+ */
18
+ const plugin = (options = {}) => {
19
+ return [
20
+ (0, _powerlines_plugin_env.default)(options.env),
21
+ {
22
+ name: "open-telemetry",
23
+ async prepare() {
24
+ this.debug(`Preparing the OpenTelemetry runtime artifacts for the Powerlines project.`);
25
+ return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_trace_builtin.TraceBuiltin, {}));
26
+ }
27
+ },
28
+ {
29
+ name: "open-telemetry:automd-generator",
30
+ config() {
31
+ return { automd: (0, defu.default)(options.automd ?? {}, { generators: { trace: require_helpers_automd_generator.trace(this) } }) };
32
+ }
33
+ },
34
+ (0, _powerlines_plugin_automd.default)(options.automd)
35
+ ];
36
+ };
37
+
38
+ //#endregion
39
+ exports.default = plugin;
40
+ exports.plugin = plugin;
package/dist/index.mjs CHANGED
@@ -1,2 +1,35 @@
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};
1
+ import { trace } from "./helpers/automd-generator.mjs";
2
+ import { TraceBuiltin } from "./components/trace-builtin.mjs";
3
+ import { createComponent } from "@alloy-js/core/jsx-runtime";
4
+ import defu from "defu";
5
+ import { render } from "@powerlines/plugin-alloy/render";
6
+ import automd from "@powerlines/plugin-automd";
7
+ import env from "@powerlines/plugin-env";
8
+
9
+ //#region src/index.tsx
10
+ /**
11
+ * A Powerlines plugin to inject environment variables into the source code.
12
+ */
13
+ const plugin = (options = {}) => {
14
+ return [
15
+ env(options.env),
16
+ {
17
+ name: "open-telemetry",
18
+ async prepare() {
19
+ this.debug(`Preparing the OpenTelemetry runtime artifacts for the Powerlines project.`);
20
+ return render(this, createComponent(TraceBuiltin, {}));
21
+ }
22
+ },
23
+ {
24
+ name: "open-telemetry:automd-generator",
25
+ config() {
26
+ return { automd: defu(options.automd ?? {}, { generators: { trace: trace(this) } }) };
27
+ }
28
+ },
29
+ automd(options.automd)
30
+ ];
31
+ };
32
+
33
+ //#endregion
34
+ export { plugin as default, plugin };
2
35
  //# sourceMappingURL=index.mjs.map
@@ -1 +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"}
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":";;;;;;;;;;;;;AA8BA,QAAO;EAAA,IAAO,QAAQ,IAAA;EAAM;;GAE5B,MAAQ,UAAQ;AACd,SAAS,MAAC,4EAAO;AACf,WAAA,OAAgB,MAAA,gBAAA,cAA0B,EAAA,CAAA,CAAA;;GAE9C;EAAA;;GAEE,SAAA;AACG,WAAA,EACH,QAAA,KAAA,QAAA,UAAA,EAAA,EAAA,EACK,YAAe,EACX,OAAQ,MAAA,KAAA,EAClB,EACQ,CAAC,EACL;;GAEF;EAAC,OAAI,QAAY,OAAA;EAAA"}
@@ -0,0 +1,14 @@
1
+
2
+ //#region src/types/env.ts
3
+ /**
4
+ * The base environment configuration used by Powerlines applications
5
+ *
6
+ * @remarks
7
+ * 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.
8
+ *
9
+ * @categoryDescription Platform
10
+ * The name of the platform the configuration parameter is intended for use in.
11
+ *
12
+ * @showCategories
13
+ */
14
+ //#endregion
@@ -1,2 +1,15 @@
1
- export{};
1
+ //#region src/types/env.ts
2
+ /**
3
+ * The base environment configuration used by Powerlines applications
4
+ *
5
+ * @remarks
6
+ * 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.
7
+ *
8
+ * @categoryDescription Platform
9
+ * The name of the platform the configuration parameter is intended for use in.
10
+ *
11
+ * @showCategories
12
+ */
13
+ //#endregion
14
+ export { };
2
15
  //# sourceMappingURL=env.mjs.map
@@ -1 +1 @@
1
- export{};
1
+ export { };
@@ -1 +1 @@
1
- export{};
1
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-open-telemetry",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "private": false,
5
5
  "description": "A package containing a Powerlines plugin for registering OpenTelemetry integration at runtime.",
6
6
  "keywords": [
@@ -170,9 +170,9 @@
170
170
  "@alloy-js/json": "0.23.0-dev.2",
171
171
  "@alloy-js/markdown": "0.23.0-dev.1",
172
172
  "@alloy-js/typescript": "0.23.0-dev.4",
173
- "@powerlines/plugin-alloy": "^0.26.76",
174
- "@powerlines/plugin-automd": "^0.1.457",
175
- "@powerlines/plugin-plugin": "^0.12.408",
173
+ "@powerlines/plugin-alloy": "^0.26.77",
174
+ "@powerlines/plugin-automd": "^0.1.458",
175
+ "@powerlines/plugin-plugin": "^0.12.409",
176
176
  "@storm-software/config-tools": "^1.190.1",
177
177
  "@stryke/convert": "^0.7.3",
178
178
  "@stryke/env": "^0.20.87",
@@ -184,7 +184,7 @@
184
184
  "@stryke/types": "^0.12.0",
185
185
  "automd": "^0.4.3",
186
186
  "defu": "^6.1.7",
187
- "powerlines": "^0.46.4",
187
+ "powerlines": "^0.46.5",
188
188
  "c12": "^3.3.4"
189
189
  },
190
190
  "devDependencies": {
@@ -206,5 +206,5 @@
206
206
  "@opentelemetry/sdk-trace-base": ">=2.0.0 <3.0.0"
207
207
  },
208
208
  "publishConfig": { "access": "public" },
209
- "gitHead": "2e5eff0d36cb4a1a54242017a16c5af5d9ce2cc3"
209
+ "gitHead": "9af888c54e58a82744cc334a6b80da52429fa0ac"
210
210
  }