renovate 43.277.1 → 43.278.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/instrumentation/file-exporter.js +50 -0
- package/dist/instrumentation/file-exporter.js.map +1 -0
- package/dist/instrumentation/index.js +3 -1
- package/dist/instrumentation/index.js.map +1 -1
- package/dist/instrumentation/utils.js +8 -2
- package/dist/instrumentation/utils.js.map +1 -1
- package/package.json +2 -1
- package/renovate-schema.json +2 -2
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { diag } from "@opentelemetry/api";
|
|
2
|
+
import { appendFile } from "node:fs/promises";
|
|
3
|
+
import { JsonTraceSerializer } from "@opentelemetry/otlp-transformer";
|
|
4
|
+
//#region lib/instrumentation/file-exporter.ts
|
|
5
|
+
const ExportResultCode = {
|
|
6
|
+
SUCCESS: 0,
|
|
7
|
+
FAILED: 1
|
|
8
|
+
};
|
|
9
|
+
var FileSpanExporter = class {
|
|
10
|
+
filePath;
|
|
11
|
+
stopped = false;
|
|
12
|
+
pendingWrites = /* @__PURE__ */ new Set();
|
|
13
|
+
constructor(filePath) {
|
|
14
|
+
this.filePath = filePath;
|
|
15
|
+
}
|
|
16
|
+
export(spans, resultCallback) {
|
|
17
|
+
if (this.stopped) {
|
|
18
|
+
resultCallback({ code: ExportResultCode.FAILED });
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const pending = this.writeSpans(spans).then(() => resultCallback({ code: ExportResultCode.SUCCESS }), (error) => {
|
|
22
|
+
diag.error("FileSpanExporter failed to write spans", error);
|
|
23
|
+
resultCallback({
|
|
24
|
+
code: ExportResultCode.FAILED,
|
|
25
|
+
error
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
this.pendingWrites.add(pending);
|
|
29
|
+
pending.finally(() => this.pendingWrites.delete(pending));
|
|
30
|
+
}
|
|
31
|
+
async writeSpans(spans) {
|
|
32
|
+
const serialized = JsonTraceSerializer.serializeRequest(spans);
|
|
33
|
+
/* v8 ignore start -- upstream type allows `undefined`, but the JSON serializer never returns it */
|
|
34
|
+
if (serialized === void 0) return;
|
|
35
|
+
/* v8 ignore stop */
|
|
36
|
+
const line = `${Buffer.from(serialized).toString("utf-8")}\n`;
|
|
37
|
+
await appendFile(this.filePath, line, "utf-8");
|
|
38
|
+
}
|
|
39
|
+
async shutdown() {
|
|
40
|
+
this.stopped = true;
|
|
41
|
+
await this.forceFlush();
|
|
42
|
+
}
|
|
43
|
+
async forceFlush() {
|
|
44
|
+
await Promise.all(this.pendingWrites);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { ExportResultCode, FileSpanExporter };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=file-exporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-exporter.js","names":[],"sources":["../../lib/instrumentation/file-exporter.ts"],"sourcesContent":["import { appendFile } from 'node:fs/promises';\nimport { diag } from '@opentelemetry/api';\nimport { JsonTraceSerializer } from '@opentelemetry/otlp-transformer';\nimport type { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-base';\n\n// Taken from https://github.com/open-telemetry/opentelemetry-js/blob/2.10.0/packages/opentelemetry-core/src/ExportResult.ts and inlined, as we don't need to add an unnecessary dependency for this type that doesn't change.\n// A plain object is used instead of a real `enum`, since this repo runs `.ts` files directly via Node's type-stripping, which cannot emit runtime code for `enum`.\nexport const ExportResultCode = {\n SUCCESS: 0,\n FAILED: 1,\n} as const;\n\nexport type ExportResultCode =\n (typeof ExportResultCode)[keyof typeof ExportResultCode];\n\nexport class FileSpanExporter implements SpanExporter {\n private readonly filePath: string;\n private stopped = false;\n private readonly pendingWrites = new Set<Promise<void>>();\n\n constructor(filePath: string) {\n this.filePath = filePath;\n }\n\n export(\n spans: ReadableSpan[],\n resultCallback: (result: { code: number; error?: Error }) => void,\n ): void {\n if (this.stopped) {\n resultCallback({ code: ExportResultCode.FAILED });\n return;\n }\n\n const pending = this.writeSpans(spans).then(\n () => resultCallback({ code: ExportResultCode.SUCCESS }),\n (error) => {\n diag.error('FileSpanExporter failed to write spans', error);\n resultCallback({ code: ExportResultCode.FAILED, error });\n },\n );\n this.pendingWrites.add(pending);\n void pending.finally(() => this.pendingWrites.delete(pending));\n }\n\n private async writeSpans(spans: ReadableSpan[]): Promise<void> {\n const serialized = JsonTraceSerializer.serializeRequest(spans);\n /* v8 ignore start -- upstream type allows `undefined`, but the JSON serializer never returns it */\n if (serialized === undefined) {\n return;\n }\n /* v8 ignore stop */\n const line = `${Buffer.from(serialized).toString('utf-8')}\\n`;\n await appendFile(this.filePath, line, 'utf-8');\n }\n\n async shutdown(): Promise<void> {\n this.stopped = true;\n await this.forceFlush();\n }\n\n async forceFlush(): Promise<void> {\n await Promise.all(this.pendingWrites);\n }\n}\n"],"mappings":";;;;AAOA,MAAa,mBAAmB;CAC9B,SAAS;CACT,QAAQ;AACV;AAKA,IAAa,mBAAb,MAAsD;CACpD;CACA,UAAkB;CAClB,gCAAiC,IAAI,IAAmB;CAExD,YAAY,UAAkB;EAC5B,KAAK,WAAW;CAClB;CAEA,OACE,OACA,gBACM;EACN,IAAI,KAAK,SAAS;GAChB,eAAe,EAAE,MAAM,iBAAiB,OAAO,CAAC;GAChD;EACF;EAEA,MAAM,UAAU,KAAK,WAAW,KAAK,CAAC,CAAC,WAC/B,eAAe,EAAE,MAAM,iBAAiB,QAAQ,CAAC,IACtD,UAAU;GACT,KAAK,MAAM,0CAA0C,KAAK;GAC1D,eAAe;IAAE,MAAM,iBAAiB;IAAQ;GAAM,CAAC;EACzD,CACF;EACA,KAAK,cAAc,IAAI,OAAO;EAC9B,QAAa,cAAc,KAAK,cAAc,OAAO,OAAO,CAAC;CAC/D;CAEA,MAAc,WAAW,OAAsC;EAC7D,MAAM,aAAa,oBAAoB,iBAAiB,KAAK;;EAE7D,IAAI,eAAe,KAAA,GACjB;;EAGF,MAAM,OAAO,GAAG,OAAO,KAAK,UAAU,CAAC,CAAC,SAAS,OAAO,EAAE;EAC1D,MAAM,WAAW,KAAK,UAAU,MAAM,OAAO;CAC/C;CAEA,MAAM,WAA0B;EAC9B,KAAK,UAAU;EACf,MAAM,KAAK,WAAW;CACxB;CAEA,MAAM,aAA4B;EAChC,MAAM,QAAQ,IAAI,KAAK,aAAa;CACtC;AACF"}
|
|
@@ -2,7 +2,8 @@ import { pkg } from "../expose.js";
|
|
|
2
2
|
import { GetDatasourceReleasesSpanProcessor } from "../modules/datasource/span-processor.js";
|
|
3
3
|
import { GitOperationSpanProcessor } from "../util/git/span-processor.js";
|
|
4
4
|
import { getResourceDetectors } from "./detectors.js";
|
|
5
|
-
import {
|
|
5
|
+
import { FileSpanExporter } from "./file-exporter.js";
|
|
6
|
+
import { getFileExporterPath, isFileExporterEnabled, isTraceDebuggingEnabled, isTraceSendingEnabled, isTracingEnabled, massageThrowable } from "./utils.js";
|
|
6
7
|
import { isPromise } from "@sindresorhus/is";
|
|
7
8
|
import { ClientRequest, ServerResponse } from "node:http";
|
|
8
9
|
import * as api from "@opentelemetry/api";
|
|
@@ -32,6 +33,7 @@ function init() {
|
|
|
32
33
|
const exporter = new OTLPTraceExporter();
|
|
33
34
|
spanProcessors.push(new BatchSpanProcessor(exporter));
|
|
34
35
|
}
|
|
36
|
+
if (isFileExporterEnabled()) spanProcessors.push(new BatchSpanProcessor(new FileSpanExporter(getFileExporterPath())));
|
|
35
37
|
const env = process.env;
|
|
36
38
|
const baseResource = resourceFromAttributes({
|
|
37
39
|
[ATTR_SERVICE_NAME]: env.OTEL_SERVICE_NAME ?? "renovate",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../lib/instrumentation/index.ts"],"sourcesContent":["import { ClientRequest, ServerResponse } from 'node:http';\nimport type { Context, Span, Tracer, TracerProvider } from '@opentelemetry/api';\nimport * as api from '@opentelemetry/api';\nimport { ProxyTracerProvider, SpanStatusCode } from '@opentelemetry/api';\nimport { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\nimport type { Instrumentation } from '@opentelemetry/instrumentation';\nimport { registerInstrumentations } from '@opentelemetry/instrumentation';\nimport { BunyanInstrumentation } from '@opentelemetry/instrumentation-bunyan';\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http';\nimport { RedisInstrumentation } from '@opentelemetry/instrumentation-redis';\nimport {\n detectResources,\n resourceFromAttributes,\n} from '@opentelemetry/resources';\nimport {\n BatchSpanProcessor,\n ConsoleSpanExporter,\n SimpleSpanProcessor,\n type SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';\nimport {\n ATTR_SERVICE_NAME,\n ATTR_SERVICE_VERSION,\n} from '@opentelemetry/semantic-conventions';\nimport { isPromise } from '@sindresorhus/is';\nimport { pkg } from '../expose.ts';\nimport { GetDatasourceReleasesSpanProcessor } from '../modules/datasource/span-processor.ts';\nimport { GitOperationSpanProcessor } from '../util/git/span-processor.ts';\nimport { getResourceDetectors } from './detectors.ts';\nimport type { RenovateSpanOptions } from './types.ts';\nimport {\n isTraceDebuggingEnabled,\n isTraceSendingEnabled,\n isTracingEnabled,\n massageThrowable,\n} from './utils.ts';\n\nlet instrumentations: Instrumentation[] = [];\n\nexport function init(): void {\n const spanProcessors: SpanProcessor[] = [\n new GitOperationSpanProcessor(),\n new GetDatasourceReleasesSpanProcessor(),\n ];\n\n if (!isTracingEnabled()) {\n const traceProvider = new NodeTracerProvider({ spanProcessors });\n traceProvider.register({\n contextManager: new AsyncLocalStorageContextManager(),\n });\n return;\n }\n\n // v8 ignore if -- TODO add tests\n if (process.env.OTEL_LOG_LEVEL) {\n api.diag.setLogger(\n new api.DiagConsoleLogger(),\n api.DiagLogLevel[\n process.env.OTEL_LOG_LEVEL.toUpperCase() as keyof typeof api.DiagLogLevel\n ],\n );\n }\n\n // add processors\n if (isTraceDebuggingEnabled()) {\n spanProcessors.push(new SimpleSpanProcessor(new ConsoleSpanExporter()));\n }\n\n // OTEL specification environment variable\n if (isTraceSendingEnabled()) {\n const exporter = new OTLPTraceExporter();\n spanProcessors.push(new BatchSpanProcessor(exporter));\n }\n\n const env = process.env; // don't use getEnv() here to avoid circular dependency with env variables used in the resource detectors\n const baseResource = resourceFromAttributes({\n // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#semantic-attributes-with-sdk-provided-default-value\n [ATTR_SERVICE_NAME]: env.OTEL_SERVICE_NAME ?? 'renovate',\n // https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n // https://github.com/open-telemetry/opentelemetry-js/blob/e9d3c71918635d490b6a9ac9f8259265b38394d0/semantic-conventions/src/experimental_attributes.ts#L7688\n ['service.namespace']: env.OTEL_SERVICE_NAMESPACE ?? 'renovatebot.com',\n [ATTR_SERVICE_VERSION]: env.OTEL_SERVICE_VERSION ?? pkg.version,\n });\n\n const detectedResource = detectResources({\n detectors: getResourceDetectors(env),\n });\n\n const traceProvider = new NodeTracerProvider({\n resource: baseResource.merge(detectedResource),\n spanProcessors,\n });\n\n const contextManager = new AsyncLocalStorageContextManager();\n traceProvider.register({\n contextManager,\n });\n\n instrumentations = [\n new HttpInstrumentation({\n /* v8 ignore start -- not easily testable */\n applyCustomAttributesOnSpan: (span, request, response) => {\n // ignore 404 errors when the branch protection of Github could not be found. This is expected if no rules are configured\n if (\n request instanceof ClientRequest &&\n request.host === `api.github.com` &&\n request.path.endsWith(`/protection`) &&\n response.statusCode === 404\n ) {\n span.setStatus({ code: SpanStatusCode.OK });\n } else if (\n request instanceof ClientRequest &&\n request.path === '/v2/' &&\n request.method === 'GET' &&\n !request.getHeader('authorization') &&\n response instanceof ServerResponse &&\n response.getHeader('www-authenticate') &&\n response.getHeader('docker-distribution-api-version') &&\n response.statusCode === 401\n ) {\n // Docker API test expects 401 with `www-authenticate` header when registry requires authentication, so ignore this error\n span.setStatus({ code: SpanStatusCode.OK });\n }\n },\n /* v8 ignore stop -- not easily testable */\n }),\n new BunyanInstrumentation(),\n new RedisInstrumentation(),\n ];\n registerInstrumentations({\n instrumentations,\n });\n}\n\n// https://github.com/open-telemetry/opentelemetry-js-api/issues/34\n/* v8 ignore next -- not easily testable */\nexport async function shutdown(): Promise<void> {\n const traceProvider = getTracerProvider();\n if (traceProvider instanceof NodeTracerProvider) {\n await traceProvider.shutdown();\n } else if (traceProvider instanceof ProxyTracerProvider) {\n const delegateProvider = traceProvider.getDelegate();\n if (delegateProvider instanceof NodeTracerProvider) {\n await delegateProvider.shutdown();\n }\n }\n}\n\nexport function disableInstrumentations(): void {\n for (const instrumentation of instrumentations) {\n instrumentation.disable();\n }\n}\n\nexport function getTracerProvider(): TracerProvider {\n return api.trace.getTracerProvider();\n}\n\nfunction getTracer(): Tracer {\n return getTracerProvider().getTracer('renovate');\n}\n\nexport function instrument<F extends () => ReturnType<F>>(\n name: string,\n fn: F,\n): ReturnType<F>;\nexport function instrument<F extends () => ReturnType<F>>(\n name: string,\n fn: F,\n options: RenovateSpanOptions,\n): ReturnType<F>;\nexport function instrument<F extends () => ReturnType<F>>(\n name: string,\n fn: F,\n options: RenovateSpanOptions,\n context: Context,\n): ReturnType<F>;\nexport function instrument<F extends () => ReturnType<F>>(\n name: string,\n fn: F,\n options: RenovateSpanOptions = {},\n context: Context = api.context.active(),\n): ReturnType<F> {\n return getTracer().startActiveSpan(name, options, context, (span: Span) => {\n try {\n const ret = fn();\n if (isPromise(ret)) {\n return ret\n .catch((e) => {\n span.recordException(e);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: massageThrowable(e),\n });\n throw e;\n })\n .finally(() => span.end()) as ReturnType<F>;\n }\n span.end();\n return ret;\n } catch (e) {\n span.recordException(e);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: massageThrowable(e),\n });\n span.end();\n throw e;\n }\n });\n}\n"],"mappings":";;;;;;;;;;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index.js","names":[],"sources":["../../lib/instrumentation/index.ts"],"sourcesContent":["import { ClientRequest, ServerResponse } from 'node:http';\nimport type { Context, Span, Tracer, TracerProvider } from '@opentelemetry/api';\nimport * as api from '@opentelemetry/api';\nimport { ProxyTracerProvider, SpanStatusCode } from '@opentelemetry/api';\nimport { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\nimport type { Instrumentation } from '@opentelemetry/instrumentation';\nimport { registerInstrumentations } from '@opentelemetry/instrumentation';\nimport { BunyanInstrumentation } from '@opentelemetry/instrumentation-bunyan';\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http';\nimport { RedisInstrumentation } from '@opentelemetry/instrumentation-redis';\nimport {\n detectResources,\n resourceFromAttributes,\n} from '@opentelemetry/resources';\nimport {\n BatchSpanProcessor,\n ConsoleSpanExporter,\n SimpleSpanProcessor,\n type SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';\nimport {\n ATTR_SERVICE_NAME,\n ATTR_SERVICE_VERSION,\n} from '@opentelemetry/semantic-conventions';\nimport { isPromise } from '@sindresorhus/is';\nimport { pkg } from '../expose.ts';\nimport { GetDatasourceReleasesSpanProcessor } from '../modules/datasource/span-processor.ts';\nimport { GitOperationSpanProcessor } from '../util/git/span-processor.ts';\nimport { getResourceDetectors } from './detectors.ts';\nimport { FileSpanExporter } from './file-exporter.ts';\nimport type { RenovateSpanOptions } from './types.ts';\nimport {\n getFileExporterPath,\n isFileExporterEnabled,\n isTraceDebuggingEnabled,\n isTraceSendingEnabled,\n isTracingEnabled,\n massageThrowable,\n} from './utils.ts';\n\nlet instrumentations: Instrumentation[] = [];\n\nexport function init(): void {\n const spanProcessors: SpanProcessor[] = [\n new GitOperationSpanProcessor(),\n new GetDatasourceReleasesSpanProcessor(),\n ];\n\n if (!isTracingEnabled()) {\n const traceProvider = new NodeTracerProvider({ spanProcessors });\n traceProvider.register({\n contextManager: new AsyncLocalStorageContextManager(),\n });\n return;\n }\n\n // v8 ignore if -- TODO add tests\n if (process.env.OTEL_LOG_LEVEL) {\n api.diag.setLogger(\n new api.DiagConsoleLogger(),\n api.DiagLogLevel[\n process.env.OTEL_LOG_LEVEL.toUpperCase() as keyof typeof api.DiagLogLevel\n ],\n );\n }\n\n // add processors\n if (isTraceDebuggingEnabled()) {\n spanProcessors.push(new SimpleSpanProcessor(new ConsoleSpanExporter()));\n }\n\n // OTEL specification environment variable\n if (isTraceSendingEnabled()) {\n const exporter = new OTLPTraceExporter();\n spanProcessors.push(new BatchSpanProcessor(exporter));\n }\n\n if (isFileExporterEnabled()) {\n spanProcessors.push(\n new BatchSpanProcessor(new FileSpanExporter(getFileExporterPath())),\n );\n }\n\n const env = process.env; // don't use getEnv() here to avoid circular dependency with env variables used in the resource detectors\n const baseResource = resourceFromAttributes({\n // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#semantic-attributes-with-sdk-provided-default-value\n [ATTR_SERVICE_NAME]: env.OTEL_SERVICE_NAME ?? 'renovate',\n // https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n // https://github.com/open-telemetry/opentelemetry-js/blob/e9d3c71918635d490b6a9ac9f8259265b38394d0/semantic-conventions/src/experimental_attributes.ts#L7688\n ['service.namespace']: env.OTEL_SERVICE_NAMESPACE ?? 'renovatebot.com',\n [ATTR_SERVICE_VERSION]: env.OTEL_SERVICE_VERSION ?? pkg.version,\n });\n\n const detectedResource = detectResources({\n detectors: getResourceDetectors(env),\n });\n\n const traceProvider = new NodeTracerProvider({\n resource: baseResource.merge(detectedResource),\n spanProcessors,\n });\n\n const contextManager = new AsyncLocalStorageContextManager();\n traceProvider.register({\n contextManager,\n });\n\n instrumentations = [\n new HttpInstrumentation({\n /* v8 ignore start -- not easily testable */\n applyCustomAttributesOnSpan: (span, request, response) => {\n // ignore 404 errors when the branch protection of Github could not be found. This is expected if no rules are configured\n if (\n request instanceof ClientRequest &&\n request.host === `api.github.com` &&\n request.path.endsWith(`/protection`) &&\n response.statusCode === 404\n ) {\n span.setStatus({ code: SpanStatusCode.OK });\n } else if (\n request instanceof ClientRequest &&\n request.path === '/v2/' &&\n request.method === 'GET' &&\n !request.getHeader('authorization') &&\n response instanceof ServerResponse &&\n response.getHeader('www-authenticate') &&\n response.getHeader('docker-distribution-api-version') &&\n response.statusCode === 401\n ) {\n // Docker API test expects 401 with `www-authenticate` header when registry requires authentication, so ignore this error\n span.setStatus({ code: SpanStatusCode.OK });\n }\n },\n /* v8 ignore stop -- not easily testable */\n }),\n new BunyanInstrumentation(),\n new RedisInstrumentation(),\n ];\n registerInstrumentations({\n instrumentations,\n });\n}\n\n// https://github.com/open-telemetry/opentelemetry-js-api/issues/34\n/* v8 ignore next -- not easily testable */\nexport async function shutdown(): Promise<void> {\n const traceProvider = getTracerProvider();\n if (traceProvider instanceof NodeTracerProvider) {\n await traceProvider.shutdown();\n } else if (traceProvider instanceof ProxyTracerProvider) {\n const delegateProvider = traceProvider.getDelegate();\n if (delegateProvider instanceof NodeTracerProvider) {\n await delegateProvider.shutdown();\n }\n }\n}\n\nexport function disableInstrumentations(): void {\n for (const instrumentation of instrumentations) {\n instrumentation.disable();\n }\n}\n\nexport function getTracerProvider(): TracerProvider {\n return api.trace.getTracerProvider();\n}\n\nfunction getTracer(): Tracer {\n return getTracerProvider().getTracer('renovate');\n}\n\nexport function instrument<F extends () => ReturnType<F>>(\n name: string,\n fn: F,\n): ReturnType<F>;\nexport function instrument<F extends () => ReturnType<F>>(\n name: string,\n fn: F,\n options: RenovateSpanOptions,\n): ReturnType<F>;\nexport function instrument<F extends () => ReturnType<F>>(\n name: string,\n fn: F,\n options: RenovateSpanOptions,\n context: Context,\n): ReturnType<F>;\nexport function instrument<F extends () => ReturnType<F>>(\n name: string,\n fn: F,\n options: RenovateSpanOptions = {},\n context: Context = api.context.active(),\n): ReturnType<F> {\n return getTracer().startActiveSpan(name, options, context, (span: Span) => {\n try {\n const ret = fn();\n if (isPromise(ret)) {\n return ret\n .catch((e) => {\n span.recordException(e);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: massageThrowable(e),\n });\n throw e;\n })\n .finally(() => span.end()) as ReturnType<F>;\n }\n span.end();\n return ret;\n } catch (e) {\n span.recordException(e);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: massageThrowable(e),\n });\n span.end();\n throw e;\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0CA,IAAI,mBAAsC,CAAC;AAE3C,SAAgB,OAAa;CAC3B,MAAM,iBAAkC,CACtC,IAAI,0BAA0B,GAC9B,IAAI,mCAAmC,CACzC;CAEA,IAAI,CAAC,iBAAiB,GAAG;EAEvB,IAD0B,mBAAmB,EAAE,eAAe,CAClD,CAAC,CAAC,SAAS,EACrB,gBAAgB,IAAI,gCAAgC,EACtD,CAAC;EACD;CACF;;CAGA,IAAI,QAAQ,IAAI,gBACd,IAAI,KAAK,UACP,IAAI,IAAI,kBAAkB,GAC1B,IAAI,aACF,QAAQ,IAAI,eAAe,YAAY,EAE3C;CAIF,IAAI,wBAAwB,GAC1B,eAAe,KAAK,IAAI,oBAAoB,IAAI,oBAAoB,CAAC,CAAC;CAIxE,IAAI,sBAAsB,GAAG;EAC3B,MAAM,WAAW,IAAI,kBAAkB;EACvC,eAAe,KAAK,IAAI,mBAAmB,QAAQ,CAAC;CACtD;CAEA,IAAI,sBAAsB,GACxB,eAAe,KACb,IAAI,mBAAmB,IAAI,iBAAiB,oBAAoB,CAAC,CAAC,CACpE;CAGF,MAAM,MAAM,QAAQ;CACpB,MAAM,eAAe,uBAAuB;GAEzC,oBAAoB,IAAI,qBAAqB;GAG7C,sBAAsB,IAAI,0BAA0B;GACpD,uBAAuB,IAAI,wBAAwB,IAAI;CAC1D,CAAC;CAED,MAAM,mBAAmB,gBAAgB,EACvC,WAAW,qBAAqB,GAAG,EACrC,CA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AI,UAAU,GAAG,GACf,OAAO,IACJ,OAAO,MAAM;IACZ,KAAK,gBAAgB,CAAC;IACtB,KAAK,UAAU;KACb,MAAM,eAAe;KACrB,SAAS,iBAAiB,CAAC;IAC7B,CAAC;IACD,MAAM;GACR,CAAC,CAAC,CACD,cAAc,KAAK,IAAI,CAAC;GAE7B,KAAK,IAAI;GACT,OAAO;EACT,SAAS,GAAG;GACV,KAAK,gBAAgB,CAAC;GACtB,KAAK,UAAU;IACb,MAAM,eAAe;IACrB,SAAS,iBAAiB,CAAC;GAC7B,CAAC;GACD,KAAK,IAAI;GACT,MAAM;EACR;CACF,CAAC;AACH"}
|
|
@@ -2,7 +2,7 @@ import { getEnv } from "../util/env.js";
|
|
|
2
2
|
import { isNullOrUndefined } from "@sindresorhus/is";
|
|
3
3
|
//#region lib/instrumentation/utils.ts
|
|
4
4
|
function isTracingEnabled() {
|
|
5
|
-
return isTraceDebuggingEnabled() || isTraceSendingEnabled();
|
|
5
|
+
return isTraceDebuggingEnabled() || isTraceSendingEnabled() || isFileExporterEnabled();
|
|
6
6
|
}
|
|
7
7
|
function isTraceDebuggingEnabled() {
|
|
8
8
|
return !!getEnv().RENOVATE_TRACING_CONSOLE_EXPORTER;
|
|
@@ -10,12 +10,18 @@ function isTraceDebuggingEnabled() {
|
|
|
10
10
|
function isTraceSendingEnabled() {
|
|
11
11
|
return !!getEnv().OTEL_EXPORTER_OTLP_ENDPOINT;
|
|
12
12
|
}
|
|
13
|
+
function isFileExporterEnabled() {
|
|
14
|
+
return !!getEnv().RENOVATE_TRACING_FILE_EXPORTER_PATH;
|
|
15
|
+
}
|
|
16
|
+
function getFileExporterPath() {
|
|
17
|
+
return getEnv().RENOVATE_TRACING_FILE_EXPORTER_PATH;
|
|
18
|
+
}
|
|
13
19
|
function massageThrowable(e) {
|
|
14
20
|
if (isNullOrUndefined(e)) return;
|
|
15
21
|
if (e instanceof Error) return e.message;
|
|
16
22
|
return String(e);
|
|
17
23
|
}
|
|
18
24
|
//#endregion
|
|
19
|
-
export { isTraceDebuggingEnabled, isTraceSendingEnabled, isTracingEnabled, massageThrowable };
|
|
25
|
+
export { getFileExporterPath, isFileExporterEnabled, isTraceDebuggingEnabled, isTraceSendingEnabled, isTracingEnabled, massageThrowable };
|
|
20
26
|
|
|
21
27
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../lib/instrumentation/utils.ts"],"sourcesContent":["import { isNullOrUndefined } from '@sindresorhus/is';\nimport { getEnv } from '../util/env.ts';\n\nexport function isTracingEnabled(): boolean {\n return isTraceDebuggingEnabled()
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../lib/instrumentation/utils.ts"],"sourcesContent":["import { isNullOrUndefined } from '@sindresorhus/is';\nimport { getEnv } from '../util/env.ts';\n\nexport function isTracingEnabled(): boolean {\n return (\n isTraceDebuggingEnabled() ||\n isTraceSendingEnabled() ||\n isFileExporterEnabled()\n );\n}\n\nexport function isTraceDebuggingEnabled(): boolean {\n return !!getEnv().RENOVATE_TRACING_CONSOLE_EXPORTER;\n}\n\nexport function isTraceSendingEnabled(): boolean {\n return !!getEnv().OTEL_EXPORTER_OTLP_ENDPOINT;\n}\n\nexport function isFileExporterEnabled(): boolean {\n return !!getEnv().RENOVATE_TRACING_FILE_EXPORTER_PATH;\n}\n\nexport function getFileExporterPath(): string {\n return getEnv().RENOVATE_TRACING_FILE_EXPORTER_PATH!;\n}\n\nexport function massageThrowable(e: unknown): string | undefined {\n if (isNullOrUndefined(e)) {\n return undefined;\n }\n if (e instanceof Error) {\n return e.message;\n }\n return String(e); // oxlint-disable-line typescript/no-base-to-string\n}\n"],"mappings":";;;AAGA,SAAgB,mBAA4B;CAC1C,OACE,wBAAwB,KACxB,sBAAsB,KACtB,sBAAsB;AAE1B;AAEA,SAAgB,0BAAmC;CACjD,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;AACpB;AAEA,SAAgB,wBAAiC;CAC/C,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;AACpB;AAEA,SAAgB,wBAAiC;CAC/C,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;AACpB;AAEA,SAAgB,sBAA8B;CAC5C,OAAO,OAAO,CAAC,CAAC;AAClB;AAEA,SAAgB,iBAAiB,GAAgC;CAC/D,IAAI,kBAAkB,CAAC,GACrB;CAEF,IAAI,aAAa,OACf,OAAO,EAAE;CAEX,OAAO,OAAO,CAAC;AACjB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "renovate",
|
|
3
3
|
"description": "Automated dependency updates. Flexible so you don't need to be.",
|
|
4
|
-
"version": "43.
|
|
4
|
+
"version": "43.278.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"renovate": "dist/renovate.js",
|
|
@@ -104,6 +104,7 @@
|
|
|
104
104
|
"@opentelemetry/instrumentation-bunyan": "0.65.0",
|
|
105
105
|
"@opentelemetry/instrumentation-http": "0.220.0",
|
|
106
106
|
"@opentelemetry/instrumentation-redis": "0.68.0",
|
|
107
|
+
"@opentelemetry/otlp-transformer": "0.220.0",
|
|
107
108
|
"@opentelemetry/resource-detector-aws": "2.20.0",
|
|
108
109
|
"@opentelemetry/resource-detector-azure": "0.28.0",
|
|
109
110
|
"@opentelemetry/resource-detector-gcp": "0.55.0",
|
package/renovate-schema.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$id": "https://docs.renovatebot.com/renovate-schema.json",
|
|
3
|
-
"title": "JSON schema for Renovate 43.
|
|
3
|
+
"title": "JSON schema for Renovate 43.278.1 config files (https://renovatebot.com/)",
|
|
4
4
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
5
|
-
"x-renovate-version": "43.
|
|
5
|
+
"x-renovate-version": "43.278.1",
|
|
6
6
|
"allowComments": true,
|
|
7
7
|
"type": "object",
|
|
8
8
|
"definitions": {
|