@microsoft/opentelemetry 0.1.0-alpha.2 → 0.1.0-alpha.3
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/commonjs/a365/configuration/A365Configuration.d.ts +42 -0
- package/dist/commonjs/a365/configuration/A365Configuration.d.ts.map +1 -0
- package/dist/commonjs/a365/configuration/A365Configuration.js +162 -0
- package/dist/commonjs/a365/configuration/A365Configuration.js.map +1 -0
- package/dist/commonjs/a365/configuration/A365ConfigurationOptions.d.ts +53 -0
- package/dist/commonjs/a365/configuration/A365ConfigurationOptions.d.ts.map +1 -0
- package/dist/commonjs/a365/configuration/A365ConfigurationOptions.js +5 -0
- package/dist/commonjs/a365/configuration/A365ConfigurationOptions.js.map +1 -0
- package/dist/commonjs/a365/configuration/index.d.ts +3 -0
- package/dist/commonjs/a365/configuration/index.d.ts.map +1 -0
- package/dist/commonjs/a365/configuration/index.js +9 -0
- package/dist/commonjs/a365/configuration/index.js.map +1 -0
- package/dist/commonjs/a365/constants.d.ts +76 -0
- package/dist/commonjs/a365/constants.d.ts.map +1 -0
- package/dist/commonjs/a365/constants.js +99 -0
- package/dist/commonjs/a365/constants.js.map +1 -0
- package/dist/commonjs/a365/context/tokenContext.d.ts +25 -0
- package/dist/commonjs/a365/context/tokenContext.d.ts.map +1 -0
- package/dist/commonjs/a365/context/tokenContext.js +67 -0
- package/dist/commonjs/a365/context/tokenContext.js.map +1 -0
- package/dist/commonjs/a365/context.d.ts +31 -0
- package/dist/commonjs/a365/context.d.ts.map +1 -0
- package/dist/commonjs/a365/context.js +109 -0
- package/dist/commonjs/a365/context.js.map +1 -0
- package/dist/commonjs/a365/contracts.d.ts +250 -0
- package/dist/commonjs/a365/contracts.d.ts.map +1 -0
- package/dist/commonjs/a365/contracts.js +52 -0
- package/dist/commonjs/a365/contracts.js.map +1 -0
- package/dist/commonjs/a365/exporter/Agent365Exporter.d.ts +25 -0
- package/dist/commonjs/a365/exporter/Agent365Exporter.d.ts.map +1 -0
- package/dist/commonjs/a365/exporter/Agent365Exporter.js +220 -0
- package/dist/commonjs/a365/exporter/Agent365Exporter.js.map +1 -0
- package/dist/commonjs/a365/exporter/Agent365ExporterOptions.d.ts +43 -0
- package/dist/commonjs/a365/exporter/Agent365ExporterOptions.d.ts.map +1 -0
- package/dist/commonjs/a365/exporter/Agent365ExporterOptions.js +30 -0
- package/dist/commonjs/a365/exporter/Agent365ExporterOptions.js.map +1 -0
- package/dist/commonjs/a365/exporter/ExporterEventNames.d.ts +9 -0
- package/dist/commonjs/a365/exporter/ExporterEventNames.d.ts.map +1 -0
- package/dist/commonjs/a365/exporter/ExporterEventNames.js +15 -0
- package/dist/commonjs/a365/exporter/ExporterEventNames.js.map +1 -0
- package/dist/commonjs/a365/exporter/index.d.ts +6 -0
- package/dist/commonjs/a365/exporter/index.d.ts.map +1 -0
- package/dist/commonjs/a365/exporter/index.js +15 -0
- package/dist/commonjs/a365/exporter/index.js.map +1 -0
- package/dist/commonjs/a365/exporter/utils.d.ts +41 -0
- package/dist/commonjs/a365/exporter/utils.d.ts.map +1 -0
- package/dist/commonjs/a365/exporter/utils.js +410 -0
- package/dist/commonjs/a365/exporter/utils.js.map +1 -0
- package/dist/commonjs/a365/index.d.ts +16 -0
- package/dist/commonjs/a365/index.d.ts.map +1 -0
- package/dist/commonjs/a365/index.js +54 -0
- package/dist/commonjs/a365/index.js.map +1 -0
- package/dist/commonjs/a365/message-utils.d.ts +42 -0
- package/dist/commonjs/a365/message-utils.d.ts.map +1 -0
- package/dist/commonjs/a365/message-utils.js +116 -0
- package/dist/commonjs/a365/message-utils.js.map +1 -0
- package/dist/commonjs/a365/middleware/BaggageBuilder.d.ts +112 -0
- package/dist/commonjs/a365/middleware/BaggageBuilder.d.ts.map +1 -0
- package/dist/commonjs/a365/middleware/BaggageBuilder.js +249 -0
- package/dist/commonjs/a365/middleware/BaggageBuilder.js.map +1 -0
- package/dist/commonjs/a365/middleware/index.d.ts +2 -0
- package/dist/commonjs/a365/middleware/index.d.ts.map +1 -0
- package/dist/commonjs/a365/middleware/index.js +9 -0
- package/dist/commonjs/a365/middleware/index.js.map +1 -0
- package/dist/commonjs/a365/processors/A365SpanProcessor.d.ts +32 -0
- package/dist/commonjs/a365/processors/A365SpanProcessor.d.ts.map +1 -0
- package/dist/commonjs/a365/processors/A365SpanProcessor.js +104 -0
- package/dist/commonjs/a365/processors/A365SpanProcessor.js.map +1 -0
- package/dist/commonjs/a365/processors/PerRequestSpanProcessor.d.ts +44 -0
- package/dist/commonjs/a365/processors/PerRequestSpanProcessor.d.ts.map +1 -0
- package/dist/commonjs/a365/processors/PerRequestSpanProcessor.js +260 -0
- package/dist/commonjs/a365/processors/PerRequestSpanProcessor.js.map +1 -0
- package/dist/commonjs/a365/processors/index.d.ts +5 -0
- package/dist/commonjs/a365/processors/index.d.ts.map +1 -0
- package/dist/commonjs/a365/processors/index.js +13 -0
- package/dist/commonjs/a365/processors/index.js.map +1 -0
- package/dist/commonjs/a365/processors/util.d.ts +10 -0
- package/dist/commonjs/a365/processors/util.d.ts.map +1 -0
- package/dist/commonjs/a365/processors/util.js +56 -0
- package/dist/commonjs/a365/processors/util.js.map +1 -0
- package/dist/commonjs/a365/scopes/ExecuteToolScope.d.ts +24 -0
- package/dist/commonjs/a365/scopes/ExecuteToolScope.d.ts.map +1 -0
- package/dist/commonjs/a365/scopes/ExecuteToolScope.js +60 -0
- package/dist/commonjs/a365/scopes/ExecuteToolScope.js.map +1 -0
- package/dist/commonjs/a365/scopes/InferenceScope.d.ts +29 -0
- package/dist/commonjs/a365/scopes/InferenceScope.d.ts.map +1 -0
- package/dist/commonjs/a365/scopes/InferenceScope.js +75 -0
- package/dist/commonjs/a365/scopes/InferenceScope.js.map +1 -0
- package/dist/commonjs/a365/scopes/InvokeAgentScope.d.ts +25 -0
- package/dist/commonjs/a365/scopes/InvokeAgentScope.d.ts.map +1 -0
- package/dist/commonjs/a365/scopes/InvokeAgentScope.js +84 -0
- package/dist/commonjs/a365/scopes/InvokeAgentScope.js.map +1 -0
- package/dist/commonjs/a365/scopes/OpenTelemetryScope.d.ts +59 -0
- package/dist/commonjs/a365/scopes/OpenTelemetryScope.d.ts.map +1 -0
- package/dist/commonjs/a365/scopes/OpenTelemetryScope.js +199 -0
- package/dist/commonjs/a365/scopes/OpenTelemetryScope.js.map +1 -0
- package/dist/commonjs/a365/scopes/OutputScope.d.ts +26 -0
- package/dist/commonjs/a365/scopes/OutputScope.d.ts.map +1 -0
- package/dist/commonjs/a365/scopes/OutputScope.js +73 -0
- package/dist/commonjs/a365/scopes/OutputScope.js.map +1 -0
- package/dist/commonjs/a365/scopes/index.d.ts +6 -0
- package/dist/commonjs/a365/scopes/index.d.ts.map +1 -0
- package/dist/commonjs/a365/scopes/index.js +16 -0
- package/dist/commonjs/a365/scopes/index.js.map +1 -0
- package/dist/commonjs/a365/utils/utils.d.ts +6 -0
- package/dist/commonjs/a365/utils/utils.d.ts.map +1 -0
- package/dist/commonjs/a365/utils/utils.js +14 -0
- package/dist/commonjs/a365/utils/utils.js.map +1 -0
- package/dist/commonjs/azureMonitor/metrics/quickpulse/types.d.ts +1 -1
- package/dist/commonjs/azureMonitor/traces/handler.d.ts.map +1 -1
- package/dist/commonjs/azureMonitor/traces/handler.js +8 -2
- package/dist/commonjs/azureMonitor/traces/handler.js.map +1 -1
- package/dist/commonjs/distro/distro.d.ts +1 -1
- package/dist/commonjs/distro/distro.d.ts.map +1 -1
- package/dist/commonjs/distro/distro.js +44 -92
- package/dist/commonjs/distro/distro.js.map +1 -1
- package/dist/commonjs/distro/types.d.ts +2 -1
- package/dist/commonjs/distro/types.d.ts.map +1 -1
- package/dist/commonjs/index.d.ts +5 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +33 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/package.json +1 -0
- package/dist/commonjs/shared/jsonConfig.d.ts +2 -1
- package/dist/commonjs/shared/jsonConfig.d.ts.map +1 -1
- package/dist/commonjs/shared/module.js +15 -11
- package/dist/commonjs/shared/module.js.map +1 -1
- package/dist/commonjs/types.d.ts +4 -30
- package/dist/commonjs/types.d.ts.map +1 -1
- package/dist/commonjs/types.js +1 -1
- package/dist/commonjs/types.js.map +1 -1
- package/dist/esm/a365/configuration/A365Configuration.d.ts +42 -0
- package/dist/esm/a365/configuration/A365Configuration.d.ts.map +1 -0
- package/dist/esm/a365/configuration/A365Configuration.js +158 -0
- package/dist/esm/a365/configuration/A365Configuration.js.map +1 -0
- package/dist/esm/a365/configuration/A365ConfigurationOptions.d.ts +53 -0
- package/dist/esm/a365/configuration/A365ConfigurationOptions.d.ts.map +1 -0
- package/dist/esm/a365/configuration/A365ConfigurationOptions.js +4 -0
- package/dist/esm/a365/configuration/A365ConfigurationOptions.js.map +1 -0
- package/dist/esm/a365/configuration/index.d.ts +3 -0
- package/dist/esm/a365/configuration/index.d.ts.map +1 -0
- package/dist/esm/a365/configuration/index.js +4 -0
- package/dist/esm/a365/configuration/index.js.map +1 -0
- package/dist/esm/a365/constants.d.ts +76 -0
- package/dist/esm/a365/constants.d.ts.map +1 -0
- package/dist/esm/a365/constants.js +95 -0
- package/dist/esm/a365/constants.js.map +1 -0
- package/dist/esm/a365/context/tokenContext.d.ts +25 -0
- package/dist/esm/a365/context/tokenContext.d.ts.map +1 -0
- package/dist/esm/a365/context/tokenContext.js +62 -0
- package/dist/esm/a365/context/tokenContext.js.map +1 -0
- package/dist/esm/a365/context.d.ts +31 -0
- package/dist/esm/a365/context.d.ts.map +1 -0
- package/dist/esm/a365/context.js +101 -0
- package/dist/esm/a365/context.js.map +1 -0
- package/dist/esm/a365/contracts.d.ts +250 -0
- package/dist/esm/a365/contracts.d.ts.map +1 -0
- package/dist/esm/a365/contracts.js +49 -0
- package/dist/esm/a365/contracts.js.map +1 -0
- package/dist/esm/a365/exporter/Agent365Exporter.d.ts +25 -0
- package/dist/esm/a365/exporter/Agent365Exporter.d.ts.map +1 -0
- package/dist/esm/a365/exporter/Agent365Exporter.js +216 -0
- package/dist/esm/a365/exporter/Agent365Exporter.js.map +1 -0
- package/dist/esm/a365/exporter/Agent365ExporterOptions.d.ts +43 -0
- package/dist/esm/a365/exporter/Agent365ExporterOptions.d.ts.map +1 -0
- package/dist/esm/a365/exporter/Agent365ExporterOptions.js +26 -0
- package/dist/esm/a365/exporter/Agent365ExporterOptions.js.map +1 -0
- package/dist/esm/a365/exporter/ExporterEventNames.d.ts +9 -0
- package/dist/esm/a365/exporter/ExporterEventNames.d.ts.map +1 -0
- package/dist/esm/a365/exporter/ExporterEventNames.js +12 -0
- package/dist/esm/a365/exporter/ExporterEventNames.js.map +1 -0
- package/dist/esm/a365/exporter/index.d.ts +6 -0
- package/dist/esm/a365/exporter/index.d.ts.map +1 -0
- package/dist/esm/a365/exporter/index.js +7 -0
- package/dist/esm/a365/exporter/index.js.map +1 -0
- package/dist/esm/a365/exporter/utils.d.ts +41 -0
- package/dist/esm/a365/exporter/utils.d.ts.map +1 -0
- package/dist/esm/a365/exporter/utils.js +398 -0
- package/dist/esm/a365/exporter/utils.js.map +1 -0
- package/dist/esm/a365/index.d.ts +16 -0
- package/dist/esm/a365/index.d.ts.map +1 -0
- package/dist/esm/a365/index.js +20 -0
- package/dist/esm/a365/index.js.map +1 -0
- package/dist/esm/a365/message-utils.d.ts +42 -0
- package/dist/esm/a365/message-utils.d.ts.map +1 -0
- package/dist/esm/a365/message-utils.js +107 -0
- package/dist/esm/a365/message-utils.js.map +1 -0
- package/dist/esm/a365/middleware/BaggageBuilder.d.ts +112 -0
- package/dist/esm/a365/middleware/BaggageBuilder.d.ts.map +1 -0
- package/dist/esm/a365/middleware/BaggageBuilder.js +244 -0
- package/dist/esm/a365/middleware/BaggageBuilder.js.map +1 -0
- package/dist/esm/a365/middleware/index.d.ts +2 -0
- package/dist/esm/a365/middleware/index.d.ts.map +1 -0
- package/dist/esm/a365/middleware/index.js +4 -0
- package/dist/esm/a365/middleware/index.js.map +1 -0
- package/dist/esm/a365/processors/A365SpanProcessor.d.ts +32 -0
- package/dist/esm/a365/processors/A365SpanProcessor.d.ts.map +1 -0
- package/dist/esm/a365/processors/A365SpanProcessor.js +100 -0
- package/dist/esm/a365/processors/A365SpanProcessor.js.map +1 -0
- package/dist/esm/a365/processors/PerRequestSpanProcessor.d.ts +44 -0
- package/dist/esm/a365/processors/PerRequestSpanProcessor.d.ts.map +1 -0
- package/dist/esm/a365/processors/PerRequestSpanProcessor.js +256 -0
- package/dist/esm/a365/processors/PerRequestSpanProcessor.js.map +1 -0
- package/dist/esm/a365/processors/index.d.ts +5 -0
- package/dist/esm/a365/processors/index.d.ts.map +1 -0
- package/dist/esm/a365/processors/index.js +6 -0
- package/dist/esm/a365/processors/index.js.map +1 -0
- package/dist/esm/a365/processors/util.d.ts +10 -0
- package/dist/esm/a365/processors/util.d.ts.map +1 -0
- package/dist/esm/a365/processors/util.js +53 -0
- package/dist/esm/a365/processors/util.js.map +1 -0
- package/dist/esm/a365/scopes/ExecuteToolScope.d.ts +24 -0
- package/dist/esm/a365/scopes/ExecuteToolScope.d.ts.map +1 -0
- package/dist/esm/a365/scopes/ExecuteToolScope.js +56 -0
- package/dist/esm/a365/scopes/ExecuteToolScope.js.map +1 -0
- package/dist/esm/a365/scopes/InferenceScope.d.ts +29 -0
- package/dist/esm/a365/scopes/InferenceScope.d.ts.map +1 -0
- package/dist/esm/a365/scopes/InferenceScope.js +71 -0
- package/dist/esm/a365/scopes/InferenceScope.js.map +1 -0
- package/dist/esm/a365/scopes/InvokeAgentScope.d.ts +25 -0
- package/dist/esm/a365/scopes/InvokeAgentScope.d.ts.map +1 -0
- package/dist/esm/a365/scopes/InvokeAgentScope.js +80 -0
- package/dist/esm/a365/scopes/InvokeAgentScope.js.map +1 -0
- package/dist/esm/a365/scopes/OpenTelemetryScope.d.ts +59 -0
- package/dist/esm/a365/scopes/OpenTelemetryScope.d.ts.map +1 -0
- package/dist/esm/a365/scopes/OpenTelemetryScope.js +195 -0
- package/dist/esm/a365/scopes/OpenTelemetryScope.js.map +1 -0
- package/dist/esm/a365/scopes/OutputScope.d.ts +26 -0
- package/dist/esm/a365/scopes/OutputScope.d.ts.map +1 -0
- package/dist/esm/a365/scopes/OutputScope.js +69 -0
- package/dist/esm/a365/scopes/OutputScope.js.map +1 -0
- package/dist/esm/a365/scopes/index.d.ts +6 -0
- package/dist/esm/a365/scopes/index.d.ts.map +1 -0
- package/dist/esm/a365/scopes/index.js +8 -0
- package/dist/esm/a365/scopes/index.js.map +1 -0
- package/dist/esm/a365/utils/utils.d.ts +6 -0
- package/dist/esm/a365/utils/utils.d.ts.map +1 -0
- package/dist/esm/a365/utils/utils.js +11 -0
- package/dist/esm/a365/utils/utils.js.map +1 -0
- package/dist/esm/azureMonitor/metrics/quickpulse/types.d.ts +1 -1
- package/dist/esm/azureMonitor/traces/handler.d.ts.map +1 -1
- package/dist/esm/azureMonitor/traces/handler.js +5 -1
- package/dist/esm/azureMonitor/traces/handler.js.map +1 -1
- package/dist/esm/distro/distro.d.ts +1 -1
- package/dist/esm/distro/distro.d.ts.map +1 -1
- package/dist/esm/distro/distro.js +44 -92
- package/dist/esm/distro/distro.js.map +1 -1
- package/dist/esm/distro/types.d.ts +2 -1
- package/dist/esm/distro/types.d.ts.map +1 -1
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/shared/jsonConfig.d.ts +2 -1
- package/dist/esm/shared/jsonConfig.d.ts.map +1 -1
- package/dist/esm/types.d.ts +4 -30
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +1 -1
- package/dist/esm/types.js.map +1 -1
- package/package.json +3 -4
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import { ExportResultCode } from "@opentelemetry/core";
|
|
4
|
+
import { ResolvedExporterOptions } from "./Agent365ExporterOptions.js";
|
|
5
|
+
import { partitionByIdentity, parseIdentityKey, hexTraceId, hexSpanId, kindName, statusName, resolveAgent365Endpoint, truncateSpan, } from "./utils.js";
|
|
6
|
+
import { Logger } from "../../shared/logging/index.js";
|
|
7
|
+
const DEFAULT_MAX_RETRIES = 3;
|
|
8
|
+
/**
|
|
9
|
+
* Agent365 span exporter.
|
|
10
|
+
*
|
|
11
|
+
* Implements `SpanExporter` from `@opentelemetry/sdk-trace-base`.
|
|
12
|
+
* Partitions spans by (tenantId, agentId), builds OTLP-like JSON payloads,
|
|
13
|
+
* and POSTs them to the Agent365 observability service with Bearer auth.
|
|
14
|
+
*/
|
|
15
|
+
export class Agent365Exporter {
|
|
16
|
+
closed = false;
|
|
17
|
+
options;
|
|
18
|
+
logger = Logger.getInstance();
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.options = new ResolvedExporterOptions(options);
|
|
21
|
+
}
|
|
22
|
+
async export(spans, resultCallback) {
|
|
23
|
+
if (this.closed) {
|
|
24
|
+
resultCallback({ code: ExportResultCode.FAILED });
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
this.logger.info(`[Agent365Exporter] Exporting ${spans.length} spans`);
|
|
29
|
+
const groups = partitionByIdentity(spans);
|
|
30
|
+
if (groups.size === 0) {
|
|
31
|
+
resultCallback({ code: ExportResultCode.SUCCESS });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let anyFailure = false;
|
|
35
|
+
const promises = [];
|
|
36
|
+
for (const [identityKey, groupSpans] of groups) {
|
|
37
|
+
const promise = this.exportGroup(identityKey, groupSpans).catch((err) => {
|
|
38
|
+
anyFailure = true;
|
|
39
|
+
this.logger.error(`[Agent365Exporter] Error exporting group ${identityKey}:`, err);
|
|
40
|
+
});
|
|
41
|
+
promises.push(promise);
|
|
42
|
+
}
|
|
43
|
+
await Promise.all(promises);
|
|
44
|
+
resultCallback({
|
|
45
|
+
code: anyFailure ? ExportResultCode.FAILED : ExportResultCode.SUCCESS,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
this.logger.error("[Agent365Exporter] Export failed:", err);
|
|
50
|
+
resultCallback({ code: ExportResultCode.FAILED });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async exportGroup(identityKey, spans) {
|
|
54
|
+
const { tenantId, agentId } = parseIdentityKey(identityKey);
|
|
55
|
+
const payload = this.buildExportRequest(spans);
|
|
56
|
+
const body = JSON.stringify(payload);
|
|
57
|
+
const endpointPath = this.options.useS2SEndpoint
|
|
58
|
+
? `/observabilityService/tenants/${encodeURIComponent(tenantId)}/agents/${encodeURIComponent(agentId)}/traces`
|
|
59
|
+
: `/observability/tenants/${encodeURIComponent(tenantId)}/agents/${encodeURIComponent(agentId)}/traces`;
|
|
60
|
+
const baseUrl = this.options.domainOverride ?? resolveAgent365Endpoint(this.options.clusterCategory);
|
|
61
|
+
const url = `${baseUrl}${endpointPath}?api-version=1`;
|
|
62
|
+
const headers = {
|
|
63
|
+
"content-type": "application/json",
|
|
64
|
+
"x-ms-tenant-id": tenantId,
|
|
65
|
+
};
|
|
66
|
+
// Resolve token
|
|
67
|
+
const token = await this.resolveToken(agentId, tenantId);
|
|
68
|
+
if (!token) {
|
|
69
|
+
this.logger.warn(`[Agent365Exporter] Skipping export for ${tenantId}/${agentId}: no token available`);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
headers["authorization"] = `Bearer ${token}`;
|
|
73
|
+
const { ok } = await this.postWithRetries(url, body, headers);
|
|
74
|
+
if (!ok) {
|
|
75
|
+
throw new Error(`Failed to export spans for ${tenantId}/${agentId}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async resolveToken(agentId, tenantId) {
|
|
79
|
+
if (!this.options.tokenResolver)
|
|
80
|
+
return null;
|
|
81
|
+
const result = this.options.tokenResolver(agentId, tenantId);
|
|
82
|
+
return result instanceof Promise ? result : result;
|
|
83
|
+
}
|
|
84
|
+
async postWithRetries(url, body, headers) {
|
|
85
|
+
let lastCorrelationId = "unknown";
|
|
86
|
+
for (let attempt = 0; attempt <= DEFAULT_MAX_RETRIES; attempt++) {
|
|
87
|
+
try {
|
|
88
|
+
const response = await fetch(url, {
|
|
89
|
+
method: "POST",
|
|
90
|
+
headers,
|
|
91
|
+
body,
|
|
92
|
+
signal: AbortSignal.timeout(this.options.httpRequestTimeoutMilliseconds),
|
|
93
|
+
});
|
|
94
|
+
const correlationId = response.headers.get("x-ms-correlation-id") ??
|
|
95
|
+
response.headers.get("x-correlation-id") ??
|
|
96
|
+
"unknown";
|
|
97
|
+
lastCorrelationId = correlationId;
|
|
98
|
+
if (response.status >= 200 && response.status < 300) {
|
|
99
|
+
return { ok: true, correlationId };
|
|
100
|
+
}
|
|
101
|
+
// Retry on transient errors
|
|
102
|
+
if ([408, 429].includes(response.status) ||
|
|
103
|
+
(response.status >= 500 && response.status < 600)) {
|
|
104
|
+
if (attempt < DEFAULT_MAX_RETRIES) {
|
|
105
|
+
const sleepMs = 200 * (attempt + 1) + Math.floor(Math.random() * 100);
|
|
106
|
+
this.logger.warn(`[Agent365Exporter] Transient error ${response.status}, retrying after ${sleepMs}ms`);
|
|
107
|
+
await sleep(sleepMs);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
this.logger.error(`[Agent365Exporter] Failed with status ${response.status}, correlation: ${correlationId}`);
|
|
112
|
+
return { ok: false, correlationId };
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
this.logger.error("[Agent365Exporter] Request error:", error);
|
|
116
|
+
if (attempt < DEFAULT_MAX_RETRIES) {
|
|
117
|
+
await sleep(200 * (attempt + 1));
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
return { ok: false, correlationId: lastCorrelationId };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return { ok: false, correlationId: lastCorrelationId };
|
|
124
|
+
}
|
|
125
|
+
buildExportRequest(spans) {
|
|
126
|
+
const scopeMap = new Map();
|
|
127
|
+
for (const sp of spans) {
|
|
128
|
+
const scope = sp.instrumentationScope;
|
|
129
|
+
const scopeKey = `${scope?.name ?? "unknown"}:${scope?.version ?? ""}`;
|
|
130
|
+
let existing = scopeMap.get(scopeKey);
|
|
131
|
+
if (!existing) {
|
|
132
|
+
existing = [];
|
|
133
|
+
scopeMap.set(scopeKey, existing);
|
|
134
|
+
}
|
|
135
|
+
existing.push(truncateSpan(this.mapSpan(sp)));
|
|
136
|
+
}
|
|
137
|
+
const scopeSpans = [];
|
|
138
|
+
for (const [scopeKey, mappedSpans] of scopeMap) {
|
|
139
|
+
const [name, version] = scopeKey.split(":");
|
|
140
|
+
scopeSpans.push({
|
|
141
|
+
scope: { name, version: version || undefined },
|
|
142
|
+
spans: mappedSpans,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
let resourceAttrs = {};
|
|
146
|
+
if (spans.length > 0 && spans[0].resource?.attributes) {
|
|
147
|
+
resourceAttrs = { ...spans[0].resource.attributes };
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
resourceSpans: [
|
|
151
|
+
{
|
|
152
|
+
resource: {
|
|
153
|
+
attributes: Object.keys(resourceAttrs).length > 0 ? resourceAttrs : null,
|
|
154
|
+
},
|
|
155
|
+
scopeSpans,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
mapSpan(sp) {
|
|
161
|
+
const ctx = sp.spanContext();
|
|
162
|
+
let parentSpanId;
|
|
163
|
+
if (sp.parentSpanContext?.spanId && sp.parentSpanContext.spanId !== "0000000000000000") {
|
|
164
|
+
parentSpanId = hexSpanId(sp.parentSpanContext.spanId);
|
|
165
|
+
}
|
|
166
|
+
const attrs = sp.attributes ? { ...sp.attributes } : {};
|
|
167
|
+
const events = (sp.events ?? []).map((ev) => {
|
|
168
|
+
const timeNs = Array.isArray(ev.time)
|
|
169
|
+
? ev.time[0] * 1_000_000_000 + ev.time[1]
|
|
170
|
+
: ev.time;
|
|
171
|
+
const evAttrs = ev.attributes && Object.keys(ev.attributes).length > 0 ? { ...ev.attributes } : null;
|
|
172
|
+
return { timeUnixNano: timeNs, name: ev.name, attributes: evAttrs };
|
|
173
|
+
});
|
|
174
|
+
const links = (sp.links ?? []).map((ln) => {
|
|
175
|
+
const lnAttrs = ln.attributes && Object.keys(ln.attributes).length > 0 ? { ...ln.attributes } : null;
|
|
176
|
+
return {
|
|
177
|
+
traceId: hexTraceId(ln.context.traceId),
|
|
178
|
+
spanId: hexSpanId(ln.context.spanId),
|
|
179
|
+
attributes: lnAttrs,
|
|
180
|
+
};
|
|
181
|
+
});
|
|
182
|
+
const status = {
|
|
183
|
+
code: statusName(sp.status?.code ?? 0),
|
|
184
|
+
message: sp.status?.message || "",
|
|
185
|
+
};
|
|
186
|
+
const startTimeNs = Array.isArray(sp.startTime)
|
|
187
|
+
? sp.startTime[0] * 1_000_000_000 + sp.startTime[1]
|
|
188
|
+
: sp.startTime;
|
|
189
|
+
const endTimeNs = Array.isArray(sp.endTime)
|
|
190
|
+
? sp.endTime[0] * 1_000_000_000 + sp.endTime[1]
|
|
191
|
+
: sp.endTime;
|
|
192
|
+
return {
|
|
193
|
+
traceId: hexTraceId(ctx.traceId),
|
|
194
|
+
spanId: hexSpanId(ctx.spanId),
|
|
195
|
+
parentSpanId,
|
|
196
|
+
name: sp.name,
|
|
197
|
+
kind: kindName(sp.kind),
|
|
198
|
+
startTimeUnixNano: startTimeNs,
|
|
199
|
+
endTimeUnixNano: endTimeNs,
|
|
200
|
+
attributes: Object.keys(attrs).length > 0 ? attrs : null,
|
|
201
|
+
events: events.length > 0 ? events : null,
|
|
202
|
+
links: links.length > 0 ? links : null,
|
|
203
|
+
status,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
async shutdown() {
|
|
207
|
+
this.closed = true;
|
|
208
|
+
}
|
|
209
|
+
async forceFlush() {
|
|
210
|
+
// No-op — spans are exported immediately on export() call
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function sleep(ms) {
|
|
214
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=Agent365Exporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Agent365Exporter.js","sourceRoot":"","sources":["../../../../src/a365/exporter/Agent365Exporter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,QAAQ,EACR,UAAU,EACV,uBAAuB,EACvB,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAEvD,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAiD9B;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IACnB,MAAM,GAAG,KAAK,CAAC;IACN,OAAO,CAA0B;IACjC,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IAE/C,YAAY,OAAiC;QAC3C,IAAI,CAAC,OAAO,GAAG,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,MAAM,CACV,KAAqB,EACrB,cAA8C;QAE9C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,cAAc,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC;YAClD,OAAO;QACT,CAAC;QAED,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,KAAK,CAAC,MAAM,QAAQ,CAAC,CAAC;YACvE,MAAM,MAAM,GAAG,mBA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9B,eAAe,EAAE,SAAS;YAC1B,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;YACxD,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;YACzC,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;YACtC,MAAM;SACP,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,0DAA0D;IAC5D,CAAC;CACF;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ClusterCategory } from "../configuration/A365ConfigurationOptions.js";
|
|
2
|
+
/**
|
|
3
|
+
* A function that resolves an authentication token for the given agent and tenant.
|
|
4
|
+
* Return null if a token cannot be provided.
|
|
5
|
+
*/
|
|
6
|
+
export type TokenResolver = (agentId: string, tenantId: string) => string | null | Promise<string | null>;
|
|
7
|
+
/**
|
|
8
|
+
* Options controlling the behavior of the Agent365 span exporter.
|
|
9
|
+
*/
|
|
10
|
+
export interface Agent365ExporterOptions {
|
|
11
|
+
/** Cluster category for endpoint resolution. @default "prod" */
|
|
12
|
+
clusterCategory?: ClusterCategory;
|
|
13
|
+
/** Token resolver for authentication. Required for batch export. */
|
|
14
|
+
tokenResolver?: TokenResolver;
|
|
15
|
+
/** When true, use the S2S endpoint path (/observabilityService/...). @default false */
|
|
16
|
+
useS2SEndpoint?: boolean;
|
|
17
|
+
/** Override the A365 observability service domain. */
|
|
18
|
+
domainOverride?: string;
|
|
19
|
+
/** Maximum span queue size before drops occur. @default 2048 */
|
|
20
|
+
maxQueueSize?: number;
|
|
21
|
+
/** Delay (ms) between automatic batch flush attempts. @default 5000 */
|
|
22
|
+
scheduledDelayMilliseconds?: number;
|
|
23
|
+
/** Maximum time (ms) for the entire export() call. @default 90000 */
|
|
24
|
+
exporterTimeoutMilliseconds?: number;
|
|
25
|
+
/** Timeout (ms) per individual HTTP request. Each retry gets a fresh timeout. @default 30000 */
|
|
26
|
+
httpRequestTimeoutMilliseconds?: number;
|
|
27
|
+
/** Maximum number of spans per export batch. @default 512 */
|
|
28
|
+
maxExportBatchSize?: number;
|
|
29
|
+
}
|
|
30
|
+
/** Resolved options with defaults applied. */
|
|
31
|
+
export declare class ResolvedExporterOptions {
|
|
32
|
+
readonly clusterCategory: ClusterCategory;
|
|
33
|
+
readonly tokenResolver?: TokenResolver;
|
|
34
|
+
readonly useS2SEndpoint: boolean;
|
|
35
|
+
readonly domainOverride?: string;
|
|
36
|
+
readonly maxQueueSize: number;
|
|
37
|
+
readonly scheduledDelayMilliseconds: number;
|
|
38
|
+
readonly exporterTimeoutMilliseconds: number;
|
|
39
|
+
readonly httpRequestTimeoutMilliseconds: number;
|
|
40
|
+
readonly maxExportBatchSize: number;
|
|
41
|
+
constructor(options?: Agent365ExporterOptions);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=Agent365ExporterOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Agent365ExporterOptions.d.ts","sourceRoot":"","sources":["../../../../src/a365/exporter/Agent365ExporterOptions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAEpF;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,KACb,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,gEAAgE;IAChE,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC,oEAAoE;IACpE,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B,uFAAuF;IACvF,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,sDAAsD;IACtD,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,uEAAuE;IACvE,0BAA0B,CAAC,EAAE,MAAM,CAAC;IAEpC,qEAAqE;IACrE,2BAA2B,CAAC,EAAE,MAAM,CAAC;IAErC,gGAAgG;IAChG,8BAA8B,CAAC,EAAE,MAAM,CAAC;IAExC,6DAA6D;IAC7D,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,8CAA8C;AAC9C,qBAAa,uBAAuB;IAClC,SAAgB,eAAe,EAAE,eAAe,CAAC;IACjD,SAAgB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9C,SAAgB,cAAc,EAAE,OAAO,CAAC;IACxC,SAAgB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxC,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,0BAA0B,EAAE,MAAM,CAAC;IACnD,SAAgB,2BAA2B,EAAE,MAAM,CAAC;IACpD,SAAgB,8BAA8B,EAAE,MAAM,CAAC;IACvD,SAAgB,kBAAkB,EAAE,MAAM,CAAC;gBAE/B,OAAO,CAAC,EAAE,uBAAuB;CAW9C"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
/** Resolved options with defaults applied. */
|
|
4
|
+
export class ResolvedExporterOptions {
|
|
5
|
+
clusterCategory;
|
|
6
|
+
tokenResolver;
|
|
7
|
+
useS2SEndpoint;
|
|
8
|
+
domainOverride;
|
|
9
|
+
maxQueueSize;
|
|
10
|
+
scheduledDelayMilliseconds;
|
|
11
|
+
exporterTimeoutMilliseconds;
|
|
12
|
+
httpRequestTimeoutMilliseconds;
|
|
13
|
+
maxExportBatchSize;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
this.clusterCategory = options?.clusterCategory ?? "prod";
|
|
16
|
+
this.tokenResolver = options?.tokenResolver;
|
|
17
|
+
this.useS2SEndpoint = options?.useS2SEndpoint ?? false;
|
|
18
|
+
this.domainOverride = options?.domainOverride;
|
|
19
|
+
this.maxQueueSize = options?.maxQueueSize ?? 2048;
|
|
20
|
+
this.scheduledDelayMilliseconds = options?.scheduledDelayMilliseconds ?? 5000;
|
|
21
|
+
this.exporterTimeoutMilliseconds = options?.exporterTimeoutMilliseconds ?? 90000;
|
|
22
|
+
this.httpRequestTimeoutMilliseconds = options?.httpRequestTimeoutMilliseconds ?? 30000;
|
|
23
|
+
this.maxExportBatchSize = options?.maxExportBatchSize ?? 512;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=Agent365ExporterOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Agent365ExporterOptions.js","sourceRoot":"","sources":["../../../../src/a365/exporter/Agent365ExporterOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AA6ClC,8CAA8C;AAC9C,MAAM,OAAO,uBAAuB;IAClB,eAAe,CAAkB;IACjC,aAAa,CAAiB;IAC9B,cAAc,CAAU;IACxB,cAAc,CAAU;IACxB,YAAY,CAAS;IACrB,0BAA0B,CAAS;IACnC,2BAA2B,CAAS;IACpC,8BAA8B,CAAS;IACvC,kBAAkB,CAAS;IAE3C,YAAY,OAAiC;QAC3C,IAAI,CAAC,eAAe,GAAG,OAAO,EAAE,eAAe,IAAI,MAAM,CAAC;QAC1D,IAAI,CAAC,aAAa,GAAG,OAAO,EAAE,aAAa,CAAC;QAC5C,IAAI,CAAC,cAAc,GAAG,OAAO,EAAE,cAAc,IAAI,KAAK,CAAC;QACvD,IAAI,CAAC,cAAc,GAAG,OAAO,EAAE,cAAc,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,IAAI,CAAC;QAClD,IAAI,CAAC,0BAA0B,GAAG,OAAO,EAAE,0BAA0B,IAAI,IAAI,CAAC;QAC9E,IAAI,CAAC,2BAA2B,GAAG,OAAO,EAAE,2BAA2B,IAAI,KAAK,CAAC;QACjF,IAAI,CAAC,8BAA8B,GAAG,OAAO,EAAE,8BAA8B,IAAI,KAAK,CAAC;QACvF,IAAI,CAAC,kBAAkB,GAAG,OAAO,EAAE,kBAAkB,IAAI,GAAG,CAAC;IAC/D,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event names used by Agent365Exporter for logging and monitoring.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum ExporterEventNames {
|
|
5
|
+
EXPORT = "agent365-export",
|
|
6
|
+
EXPORT_GROUP = "export-group",
|
|
7
|
+
EXPORT_PARTITION_SPAN_MISSING_IDENTITY = "export-partition-span-missing-identity"
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=ExporterEventNames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExporterEventNames.d.ts","sourceRoot":"","sources":["../../../../src/a365/exporter/ExporterEventNames.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,oBAAY,kBAAkB;IAC5B,MAAM,oBAAoB;IAC1B,YAAY,iBAAiB;IAC7B,sCAAsC,2CAA2C;CAClF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
/**
|
|
4
|
+
* Event names used by Agent365Exporter for logging and monitoring.
|
|
5
|
+
*/
|
|
6
|
+
export var ExporterEventNames;
|
|
7
|
+
(function (ExporterEventNames) {
|
|
8
|
+
ExporterEventNames["EXPORT"] = "agent365-export";
|
|
9
|
+
ExporterEventNames["EXPORT_GROUP"] = "export-group";
|
|
10
|
+
ExporterEventNames["EXPORT_PARTITION_SPAN_MISSING_IDENTITY"] = "export-partition-span-missing-identity";
|
|
11
|
+
})(ExporterEventNames || (ExporterEventNames = {}));
|
|
12
|
+
//# sourceMappingURL=ExporterEventNames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExporterEventNames.js","sourceRoot":"","sources":["../../../../src/a365/exporter/ExporterEventNames.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,gDAA0B,CAAA;IAC1B,mDAA6B,CAAA;IAC7B,uGAAiF,CAAA;AACnF,CAAC,EAJW,kBAAkB,KAAlB,kBAAkB,QAI7B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Agent365Exporter } from "./Agent365Exporter.js";
|
|
2
|
+
export type { Agent365ExporterOptions, TokenResolver } from "./Agent365ExporterOptions.js";
|
|
3
|
+
export { ResolvedExporterOptions } from "./Agent365ExporterOptions.js";
|
|
4
|
+
export { ExporterEventNames } from "./ExporterEventNames.js";
|
|
5
|
+
export { truncateSpan, MAX_SPAN_SIZE_BYTES } from "./utils.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/a365/exporter/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
export { Agent365Exporter } from "./Agent365Exporter.js";
|
|
4
|
+
export { ResolvedExporterOptions } from "./Agent365ExporterOptions.js";
|
|
5
|
+
export { ExporterEventNames } from "./ExporterEventNames.js";
|
|
6
|
+
export { truncateSpan, MAX_SPAN_SIZE_BYTES } from "./utils.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/a365/exporter/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ReadableSpan } from "@opentelemetry/sdk-trace-base";
|
|
2
|
+
import { SpanKind, SpanStatusCode } from "@opentelemetry/api";
|
|
3
|
+
import type { ClusterCategory } from "../configuration/A365ConfigurationOptions.js";
|
|
4
|
+
/**
|
|
5
|
+
* Partition spans by (tenantId, agentId) identity pairs.
|
|
6
|
+
* Spans missing either attribute are skipped.
|
|
7
|
+
*/
|
|
8
|
+
export declare function partitionByIdentity(spans: ReadableSpan[]): Map<string, ReadableSpan[]>;
|
|
9
|
+
/** Parse identity key back to tenant and agent IDs. */
|
|
10
|
+
export declare function parseIdentityKey(key: string): {
|
|
11
|
+
tenantId: string;
|
|
12
|
+
agentId: string;
|
|
13
|
+
};
|
|
14
|
+
/** Convert trace ID to hex string (32 hex chars). */
|
|
15
|
+
export declare function hexTraceId(value: string | number): string;
|
|
16
|
+
/** Convert span ID to hex string (16 hex chars). */
|
|
17
|
+
export declare function hexSpanId(value: string | number): string;
|
|
18
|
+
/** Convert any value to a trimmed string, or undefined if empty/null. */
|
|
19
|
+
export declare function asStr(v: unknown): string | undefined;
|
|
20
|
+
/** Get span kind name. */
|
|
21
|
+
export declare function kindName(kind: SpanKind): string;
|
|
22
|
+
/** Get status name. */
|
|
23
|
+
export declare function statusName(code: SpanStatusCode): string;
|
|
24
|
+
/**
|
|
25
|
+
* Resolve the Agent365 service endpoint base URI for a given cluster category.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveAgent365Endpoint(clusterCategory: ClusterCategory): string;
|
|
28
|
+
/** Maximum allowed span size in bytes (250KB). */
|
|
29
|
+
export declare const MAX_SPAN_SIZE_BYTES: number;
|
|
30
|
+
interface OTLPSpanLike {
|
|
31
|
+
attributes: Record<string, unknown> | null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Truncate span attributes if the serialized span exceeds MAX_SPAN_SIZE_BYTES.
|
|
35
|
+
*
|
|
36
|
+
* Phase 1: iteratively shrink fields (blobs, text, json, strings) by size priority.
|
|
37
|
+
* Phase 2 (fallback): replace remaining string attributes with overlimit sentinel.
|
|
38
|
+
*/
|
|
39
|
+
export declare function truncateSpan<T extends OTLPSpanLike>(spanDict: T): T;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/a365/exporter/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAA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