@grafana/faro-web-sdk 1.0.1 → 1.0.4
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/bundle/faro-web-sdk.iife.js +1 -1
- package/dist/cjs/config/types.js.map +1 -1
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/metas/browser/meta.js +11 -0
- package/dist/cjs/metas/browser/meta.js.map +1 -1
- package/dist/esm/config/types.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/metas/browser/meta.js +11 -0
- package/dist/esm/metas/browser/meta.js.map +1 -1
- package/dist/types/config/types.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/instrumentations/console/instrumentation.d.ts +1 -1
- package/dist/types/instrumentations/errors/instrumentation.d.ts +1 -1
- package/dist/types/instrumentations/session/instrumentation.d.ts +1 -1
- package/dist/types/instrumentations/view/instrumentation.d.ts +1 -1
- package/dist/types/instrumentations/webVitals/instrumentation.d.ts +1 -1
- package/dist/types/transports/console/transport.d.ts +1 -1
- package/dist/types/transports/fetch/transport.d.ts +1 -1
- package/package.json +3 -3
- package/dist/cjs/transports/otlp/otlpPayloadLogger.js +0 -6
- package/dist/cjs/transports/otlp/otlpPayloadLogger.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/OtelPayload.js +0 -56
- package/dist/cjs/transports/otlp/payload/OtelPayload.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/attribute/attributeUtils.js +0 -53
- package/dist/cjs/transports/otlp/payload/attribute/attributeUtils.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/attribute/index.js +0 -8
- package/dist/cjs/transports/otlp/payload/attribute/index.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/index.js +0 -6
- package/dist/cjs/transports/otlp/payload/index.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/transform/index.js +0 -7
- package/dist/cjs/transports/otlp/payload/transform/index.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/transform/transform.js +0 -169
- package/dist/cjs/transports/otlp/payload/transform/transform.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/transform/types.js +0 -3
- package/dist/cjs/transports/otlp/payload/transform/types.js.map +0 -1
- package/dist/cjs/transports/otlp/payload/types.js +0 -3
- package/dist/cjs/transports/otlp/payload/types.js.map +0 -1
- package/dist/esm/transports/otlp/otlpPayloadLogger.js +0 -3
- package/dist/esm/transports/otlp/otlpPayloadLogger.js.map +0 -1
- package/dist/esm/transports/otlp/payload/OtelPayload.js +0 -45
- package/dist/esm/transports/otlp/payload/OtelPayload.js.map +0 -1
- package/dist/esm/transports/otlp/payload/attribute/attributeUtils.js +0 -44
- package/dist/esm/transports/otlp/payload/attribute/attributeUtils.js.map +0 -1
- package/dist/esm/transports/otlp/payload/attribute/index.js +0 -2
- package/dist/esm/transports/otlp/payload/attribute/index.js.map +0 -1
- package/dist/esm/transports/otlp/payload/index.js +0 -2
- package/dist/esm/transports/otlp/payload/index.js.map +0 -1
- package/dist/esm/transports/otlp/payload/transform/index.js +0 -2
- package/dist/esm/transports/otlp/payload/transform/index.js.map +0 -1
- package/dist/esm/transports/otlp/payload/transform/transform.js +0 -158
- package/dist/esm/transports/otlp/payload/transform/transform.js.map +0 -1
- package/dist/esm/transports/otlp/payload/transform/types.js +0 -2
- package/dist/esm/transports/otlp/payload/transform/types.js.map +0 -1
- package/dist/esm/transports/otlp/payload/types.js +0 -2
- package/dist/esm/transports/otlp/payload/types.js.map +0 -1
- package/dist/types/transports/otlp/otlpPayloadLogger.d.ts +0 -1
- package/dist/types/transports/otlp/payload/OtelPayload.d.ts +0 -8
- package/dist/types/transports/otlp/payload/attribute/attributeUtils.d.ts +0 -4
- package/dist/types/transports/otlp/payload/attribute/index.d.ts +0 -1
- package/dist/types/transports/otlp/payload/index.d.ts +0 -2
- package/dist/types/transports/otlp/payload/transform/index.d.ts +0 -2
- package/dist/types/transports/otlp/payload/transform/transform.d.ts +0 -6
- package/dist/types/transports/otlp/payload/transform/types.d.ts +0 -28
- package/dist/types/transports/otlp/payload/types.d.ts +0 -6
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { SemanticAttributes, SemanticResourceAttributes, TelemetrySdkLanguageValues, } from '@opentelemetry/semantic-conventions';
|
|
2
|
-
import { TransportItemType, VERSION, } from '@grafana/faro-core';
|
|
3
|
-
import { internalLogger } from '../../otlpPayloadLogger';
|
|
4
|
-
import { isAttribute, toAttribute, toAttributeValue } from '../attribute';
|
|
5
|
-
/**
|
|
6
|
-
* Seems currently to be missing in the semantic-conventions npm package.
|
|
7
|
-
* See: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#todos
|
|
8
|
-
*
|
|
9
|
-
* Attributes are as defined by the Otel docs
|
|
10
|
-
*/
|
|
11
|
-
const SemanticBrowserAttributes = {
|
|
12
|
-
BROWSER_BRANDS: 'browser.brands',
|
|
13
|
-
BROWSER_PLATFORM: 'browser.platform',
|
|
14
|
-
BROWSER_MOBILE: 'browser.mobile',
|
|
15
|
-
BROWSER_USER_AGENT: 'browser.user_agent',
|
|
16
|
-
BROWSER_LANGUAGE: 'browser.language',
|
|
17
|
-
};
|
|
18
|
-
export function toResourceLog(transportItem) {
|
|
19
|
-
const resource = toResource(transportItem);
|
|
20
|
-
return {
|
|
21
|
-
resource,
|
|
22
|
-
scopeLogs: [toScopeLog(transportItem)],
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function toResource(transportItem) {
|
|
26
|
-
const { browser, sdk, app } = transportItem.meta;
|
|
27
|
-
return {
|
|
28
|
-
attributes: [
|
|
29
|
-
toAttribute(SemanticBrowserAttributes.BROWSER_MOBILE, browser === null || browser === void 0 ? void 0 : browser.mobile),
|
|
30
|
-
toAttribute(SemanticBrowserAttributes.BROWSER_USER_AGENT, browser === null || browser === void 0 ? void 0 : browser.userAgent),
|
|
31
|
-
toAttribute(SemanticBrowserAttributes.BROWSER_LANGUAGE, browser === null || browser === void 0 ? void 0 : browser.language),
|
|
32
|
-
toAttribute('browser.os', browser === null || browser === void 0 ? void 0 : browser.os),
|
|
33
|
-
// toAttribute(SemanticBrowserAttributes.BROWSER_BRANDS, browser?.brands),
|
|
34
|
-
toAttribute('browser.name', browser === null || browser === void 0 ? void 0 : browser.name),
|
|
35
|
-
toAttribute('browser.version', browser === null || browser === void 0 ? void 0 : browser.version),
|
|
36
|
-
toAttribute(SemanticResourceAttributes.TELEMETRY_SDK_NAME, sdk === null || sdk === void 0 ? void 0 : sdk.name),
|
|
37
|
-
toAttribute(SemanticResourceAttributes.TELEMETRY_SDK_VERSION, sdk === null || sdk === void 0 ? void 0 : sdk.version),
|
|
38
|
-
Boolean(sdk)
|
|
39
|
-
? toAttribute(SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE, TelemetrySdkLanguageValues.WEBJS)
|
|
40
|
-
: undefined,
|
|
41
|
-
toAttribute(SemanticResourceAttributes.SERVICE_NAME, app === null || app === void 0 ? void 0 : app.name),
|
|
42
|
-
toAttribute(SemanticResourceAttributes.SERVICE_VERSION, app === null || app === void 0 ? void 0 : app.version),
|
|
43
|
-
toAttribute(SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT, app === null || app === void 0 ? void 0 : app.environment),
|
|
44
|
-
].filter(isAttribute),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
export function toScopeLog(transportItem) {
|
|
48
|
-
return {
|
|
49
|
-
scope: {
|
|
50
|
-
name: '@grafana/faro-web-sdk',
|
|
51
|
-
version: VERSION,
|
|
52
|
-
},
|
|
53
|
-
logRecords: [toLogRecord(transportItem)],
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function toLogRecord(transportItem) {
|
|
57
|
-
const { type } = transportItem;
|
|
58
|
-
switch (type) {
|
|
59
|
-
case TransportItemType.LOG:
|
|
60
|
-
return toLogLogRecord(transportItem);
|
|
61
|
-
case TransportItemType.EXCEPTION:
|
|
62
|
-
return toErrorLogRecord(transportItem);
|
|
63
|
-
case TransportItemType.EVENT:
|
|
64
|
-
return toEventLogRecord(transportItem);
|
|
65
|
-
case TransportItemType.MEASUREMENT:
|
|
66
|
-
return toMeasurementLogRecord(transportItem);
|
|
67
|
-
default:
|
|
68
|
-
const error = `Unknown TransportItemType: ${type}`;
|
|
69
|
-
internalLogger.error(error);
|
|
70
|
-
throw new Error(error);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function toLogLogRecord(transportItem) {
|
|
74
|
-
var _a, _b;
|
|
75
|
-
const { meta, payload } = transportItem;
|
|
76
|
-
const timeUnixNano = toTimeUnixNano(payload.timestamp);
|
|
77
|
-
const body = toAttributeValue(payload.message);
|
|
78
|
-
return {
|
|
79
|
-
timeUnixNano,
|
|
80
|
-
severityNumber: 10,
|
|
81
|
-
severityText: 'INFO2',
|
|
82
|
-
body,
|
|
83
|
-
attributes: getCommonLogAttributes(meta),
|
|
84
|
-
traceId: (_a = payload.trace) === null || _a === void 0 ? void 0 : _a.trace_id,
|
|
85
|
-
spanId: (_b = payload.trace) === null || _b === void 0 ? void 0 : _b.trace_id,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function toEventLogRecord(transportItem) {
|
|
89
|
-
var _a, _b;
|
|
90
|
-
const { meta, payload } = transportItem;
|
|
91
|
-
const timeUnixNano = toTimeUnixNano(payload.timestamp);
|
|
92
|
-
const body = toAttributeValue(payload.name);
|
|
93
|
-
return {
|
|
94
|
-
timeUnixNano,
|
|
95
|
-
body,
|
|
96
|
-
attributes: [
|
|
97
|
-
...getCommonLogAttributes(meta),
|
|
98
|
-
toAttribute('event.name', payload.name),
|
|
99
|
-
toAttribute('event.domain', payload.domain),
|
|
100
|
-
toAttribute('event.attributes', payload.attributes),
|
|
101
|
-
].filter(isAttribute),
|
|
102
|
-
traceId: (_a = payload.trace) === null || _a === void 0 ? void 0 : _a.trace_id,
|
|
103
|
-
spanId: (_b = payload.trace) === null || _b === void 0 ? void 0 : _b.trace_id,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function toErrorLogRecord(transportItem) {
|
|
107
|
-
var _a, _b;
|
|
108
|
-
const { meta, payload } = transportItem;
|
|
109
|
-
const timeUnixNano = toTimeUnixNano(payload.timestamp);
|
|
110
|
-
return {
|
|
111
|
-
timeUnixNano,
|
|
112
|
-
attributes: [
|
|
113
|
-
...getCommonLogAttributes(meta),
|
|
114
|
-
toAttribute(SemanticAttributes.EXCEPTION_TYPE, payload.type),
|
|
115
|
-
toAttribute(SemanticAttributes.EXCEPTION_MESSAGE, payload.value),
|
|
116
|
-
// toAttribute(SemanticAttributes.EXCEPTION_STACKTRACE, undefined),
|
|
117
|
-
toAttribute('faro.error.stacktrace', payload.stacktrace),
|
|
118
|
-
].filter(isAttribute),
|
|
119
|
-
traceId: (_a = payload.trace) === null || _a === void 0 ? void 0 : _a.trace_id,
|
|
120
|
-
spanId: (_b = payload.trace) === null || _b === void 0 ? void 0 : _b.trace_id,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function toMeasurementLogRecord(transportItem) {
|
|
124
|
-
var _a, _b;
|
|
125
|
-
const { meta, payload } = transportItem;
|
|
126
|
-
const timeUnixNano = toTimeUnixNano(payload.timestamp);
|
|
127
|
-
const [measurementName, measurementValue] = Object.entries(payload.values).flat();
|
|
128
|
-
return {
|
|
129
|
-
timeUnixNano,
|
|
130
|
-
attributes: [
|
|
131
|
-
...getCommonLogAttributes(meta),
|
|
132
|
-
toAttribute('measurement.type', payload.type),
|
|
133
|
-
toAttribute('measurement.name', measurementName),
|
|
134
|
-
toAttribute('measurement.value', measurementValue),
|
|
135
|
-
].filter(isAttribute),
|
|
136
|
-
traceId: (_a = payload.trace) === null || _a === void 0 ? void 0 : _a.trace_id,
|
|
137
|
-
spanId: (_b = payload.trace) === null || _b === void 0 ? void 0 : _b.trace_id,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
function getCommonLogAttributes(meta) {
|
|
141
|
-
const { view, page, session, user } = meta;
|
|
142
|
-
return [
|
|
143
|
-
toAttribute('view.name', view === null || view === void 0 ? void 0 : view.name),
|
|
144
|
-
toAttribute(SemanticAttributes.HTTP_URL, page === null || page === void 0 ? void 0 : page.url),
|
|
145
|
-
toAttribute('page.id', page === null || page === void 0 ? void 0 : page.id),
|
|
146
|
-
toAttribute('page.attributes', page === null || page === void 0 ? void 0 : page.attributes),
|
|
147
|
-
toAttribute('session.id', session === null || session === void 0 ? void 0 : session.id),
|
|
148
|
-
toAttribute('session.attributes', session === null || session === void 0 ? void 0 : session.attributes),
|
|
149
|
-
toAttribute(SemanticAttributes.ENDUSER_ID, user === null || user === void 0 ? void 0 : user.id),
|
|
150
|
-
toAttribute('enduser.name', user === null || user === void 0 ? void 0 : user.username),
|
|
151
|
-
toAttribute('enduser.email', user === null || user === void 0 ? void 0 : user.email),
|
|
152
|
-
toAttribute('enduser.attributes', user === null || user === void 0 ? void 0 : user.attributes),
|
|
153
|
-
].filter(isAttribute);
|
|
154
|
-
}
|
|
155
|
-
function toTimeUnixNano(timestamp) {
|
|
156
|
-
return Date.parse(timestamp) * 1e6;
|
|
157
|
-
}
|
|
158
|
-
//# sourceMappingURL=transform.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../../../../src/transports/otlp/payload/transform/transform.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAOL,iBAAiB,EACjB,OAAO,GACR,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAI1E;;;;;GAKG;AACH,MAAM,yBAAyB,GAAG;IAChC,cAAc,EAAE,gBAAgB;IAChC,g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\n TelemetrySdkLanguageValues,\n} from '@opentelemetry/semantic-conventions';\n\nimport {\n EventEvent,\n ExceptionEvent,\n LogEvent,\n MeasurementEvent,\n Meta,\n TransportItem,\n TransportItemType,\n VERSION,\n} from '@grafana/faro-core';\n\nimport { internalLogger } from '../../otlpPayloadLogger';\nimport { isAttribute, toAttribute, toAttributeValue } from '../attribute';\n\nimport type { LogRecord, LogTransportItem, Resource, ScopeLog } from './types';\n\n/**\n * Seems currently to be missing in the semantic-conventions npm package.\n * See: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#todos\n *\n * Attributes are as defined by the Otel docs\n */\nconst SemanticBrowserAttributes = {\n BROWSER_BRANDS: 'browser.brands',\n BROWSER_PLATFORM: 'browser.platform',\n BROWSER_MOBILE: 'browser.mobile',\n BROWSER_USER_AGENT: 'browser.user_agent',\n BROWSER_LANGUAGE: 'browser.language',\n} as const;\n\nexport function toResourceLog(transportItem: LogTransportItem) {\n const resource = toResource(transportItem);\n\n return {\n resource,\n scopeLogs: [toScopeLog(transportItem)],\n };\n}\n\nfunction toResource(transportItem: LogTransportItem): Readonly<Resource> {\n const { browser, sdk, app } = transportItem.meta;\n\n return {\n attributes: [\n toAttribute(SemanticBrowserAttributes.BROWSER_MOBILE, browser?.mobile),\n toAttribute(SemanticBrowserAttributes.BROWSER_USER_AGENT, browser?.userAgent),\n toAttribute(SemanticBrowserAttributes.BROWSER_LANGUAGE, browser?.language),\n toAttribute('browser.os', browser?.os),\n // toAttribute(SemanticBrowserAttributes.BROWSER_BRANDS, browser?.brands),\n toAttribute('browser.name', browser?.name),\n toAttribute('browser.version', browser?.version),\n\n toAttribute(SemanticResourceAttributes.TELEMETRY_SDK_NAME, sdk?.name),\n toAttribute(SemanticResourceAttributes.TELEMETRY_SDK_VERSION, sdk?.version),\n Boolean(sdk)\n ? toAttribute(SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE, TelemetrySdkLanguageValues.WEBJS)\n : undefined,\n\n toAttribute(SemanticResourceAttributes.SERVICE_NAME, app?.name),\n toAttribute(SemanticResourceAttributes.SERVICE_VERSION, app?.version),\n toAttribute(SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT, app?.environment),\n ].filter(isAttribute),\n };\n}\n\nexport function toScopeLog(transportItem: LogTransportItem): ScopeLog {\n return {\n scope: {\n name: '@grafana/faro-web-sdk',\n version: VERSION,\n },\n logRecords: [toLogRecord(transportItem)],\n };\n}\n\nfunction toLogRecord(transportItem: LogTransportItem): LogRecord {\n const { type } = transportItem;\n\n switch (type) {\n case TransportItemType.LOG:\n return toLogLogRecord(transportItem as TransportItem<LogEvent>);\n case TransportItemType.EXCEPTION:\n return toErrorLogRecord(transportItem as TransportItem<ExceptionEvent>);\n case TransportItemType.EVENT:\n return toEventLogRecord(transportItem as TransportItem<EventEvent>);\n case TransportItemType.MEASUREMENT:\n return toMeasurementLogRecord(transportItem as TransportItem<MeasurementEvent>);\n default:\n const error = `Unknown TransportItemType: ${type}`;\n internalLogger.error(error);\n throw new Error(error);\n }\n}\n\nfunction toLogLogRecord(transportItem: TransportItem<LogEvent>): LogRecord {\n const { meta, payload } = transportItem;\n const timeUnixNano = toTimeUnixNano(payload.timestamp);\n const body = toAttributeValue(payload.message) as { stringValue: string; key: string };\n\n return {\n timeUnixNano,\n severityNumber: 10,\n severityText: 'INFO2',\n body,\n attributes: getCommonLogAttributes(meta),\n traceId: payload.trace?.trace_id,\n spanId: payload.trace?.trace_id,\n } as const;\n}\n\nfunction toEventLogRecord(transportItem: TransportItem<EventEvent>): LogRecord {\n const { meta, payload } = transportItem;\n const timeUnixNano = toTimeUnixNano(payload.timestamp);\n const body = toAttributeValue(payload.name) as { stringValue: string; key: string };\n\n return {\n timeUnixNano,\n body,\n attributes: [\n ...getCommonLogAttributes(meta),\n toAttribute('event.name', payload.name), // No prefix because this is a semantic attribute. But event.name constant is currently missing in sematic-conventions npm package\n toAttribute('event.domain', payload.domain), // No prefix because this is a semantic attribute. But event.domain constant is currently missing in sematic-conventions npm package\n toAttribute('event.attributes', payload.attributes),\n ].filter(isAttribute),\n traceId: payload.trace?.trace_id,\n spanId: payload.trace?.trace_id,\n } as const;\n}\n\nfunction toErrorLogRecord(transportItem: TransportItem<ExceptionEvent>): LogRecord {\n const { meta, payload } = transportItem;\n const timeUnixNano = toTimeUnixNano(payload.timestamp);\n\n return {\n timeUnixNano,\n attributes: [\n ...getCommonLogAttributes(meta),\n toAttribute(SemanticAttributes.EXCEPTION_TYPE, payload.type),\n toAttribute(SemanticAttributes.EXCEPTION_MESSAGE, payload.value),\n // toAttribute(SemanticAttributes.EXCEPTION_STACKTRACE, undefined),\n toAttribute('faro.error.stacktrace', payload.stacktrace),\n ].filter(isAttribute),\n traceId: payload.trace?.trace_id,\n spanId: payload.trace?.trace_id,\n } as const;\n}\n\nfunction toMeasurementLogRecord(transportItem: TransportItem<MeasurementEvent>): LogRecord {\n const { meta, payload } = transportItem;\n const timeUnixNano = toTimeUnixNano(payload.timestamp);\n const [measurementName, measurementValue] = Object.entries(payload.values).flat();\n\n return {\n timeUnixNano,\n attributes: [\n ...getCommonLogAttributes(meta),\n toAttribute('measurement.type', payload.type),\n toAttribute('measurement.name', measurementName),\n toAttribute('measurement.value', measurementValue),\n ].filter(isAttribute),\n traceId: payload.trace?.trace_id,\n spanId: payload.trace?.trace_id,\n } as const;\n}\n\nfunction getCommonLogAttributes(meta: Meta): IKeyValue[] {\n const { view, page, session, user } = meta;\n\n return [\n toAttribute('view.name', view?.name),\n toAttribute(SemanticAttributes.HTTP_URL, page?.url),\n toAttribute('page.id', page?.id),\n toAttribute('page.attributes', page?.attributes),\n toAttribute('session.id', session?.id),\n toAttribute('session.attributes', session?.attributes),\n toAttribute(SemanticAttributes.ENDUSER_ID, user?.id),\n toAttribute('enduser.name', user?.username),\n toAttribute('enduser.email', user?.email),\n toAttribute('enduser.attributes', user?.attributes),\n ].filter(isAttribute);\n}\n\nfunction toTimeUnixNano(timestamp: string): number {\n return Date.parse(timestamp) * 1e6;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/transports/otlp/payload/transform/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IKeyValue } from '@opentelemetry/otlp-transformer';\n\nimport type { APIEvent, TransportItem } from '@grafana/faro-core';\n\nexport interface Resource {\n attributes: IKeyValue[];\n}\n\nexport interface ScopeLog {\n scope: { name: string; version: string };\n logRecords: LogRecord[];\n}\n\nexport interface LogRecord {\n timeUnixNano?: number;\n severityNumber?: number;\n severityText?: string;\n body?: { stringValue: string };\n attributes?: IKeyValue[];\n traceId?: string;\n spanId?: string;\n}\n\nexport interface ResourceLog {\n resource: Resource;\n scopeLogs: ScopeLog[];\n}\n\nexport type LogTransportItem = TransportItem<Exclude<APIEvent, 'TraceEvent'>>;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/transports/otlp/payload/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ResourceLog } from './transform';\n\nexport interface OtelTransportPayload {\n readonly resourceLogs: Readonly<ResourceLog[]>;\n readonly resourceSpans: Readonly<unknown[]>;\n readonly resourceMetrics: Readonly<unknown[]>;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const internalLogger: import("@grafana/faro-core").InternalLogger;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TransportItem } from '@grafana/faro-core';
|
|
2
|
-
import type { OtelTransportPayload } from './types';
|
|
3
|
-
export declare class OtelPayload {
|
|
4
|
-
private resourceLogsWithMetas;
|
|
5
|
-
constructor(transportItem?: TransportItem);
|
|
6
|
-
getPayload(): OtelTransportPayload;
|
|
7
|
-
addResourceItem(transportItem: TransportItem): void;
|
|
8
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { IAnyValue, IKeyValue } from '@opentelemetry/otlp-transformer';
|
|
2
|
-
export declare function toAttributeValue(value: unknown): IAnyValue;
|
|
3
|
-
export declare function toAttribute(attributeName: string, attributeValue: any): IKeyValue | undefined;
|
|
4
|
-
export declare function isAttribute(item: any): item is IKeyValue;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { toAttribute, toAttributeValue, isAttribute } from './attributeUtils';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { LogTransportItem, Resource, ScopeLog } from './types';
|
|
2
|
-
export declare function toResourceLog(transportItem: LogTransportItem): {
|
|
3
|
-
resource: Readonly<Resource>;
|
|
4
|
-
scopeLogs: ScopeLog[];
|
|
5
|
-
};
|
|
6
|
-
export declare function toScopeLog(transportItem: LogTransportItem): ScopeLog;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { IKeyValue } from '@opentelemetry/otlp-transformer';
|
|
2
|
-
import type { APIEvent, TransportItem } from '@grafana/faro-core';
|
|
3
|
-
export interface Resource {
|
|
4
|
-
attributes: IKeyValue[];
|
|
5
|
-
}
|
|
6
|
-
export interface ScopeLog {
|
|
7
|
-
scope: {
|
|
8
|
-
name: string;
|
|
9
|
-
version: string;
|
|
10
|
-
};
|
|
11
|
-
logRecords: LogRecord[];
|
|
12
|
-
}
|
|
13
|
-
export interface LogRecord {
|
|
14
|
-
timeUnixNano?: number;
|
|
15
|
-
severityNumber?: number;
|
|
16
|
-
severityText?: string;
|
|
17
|
-
body?: {
|
|
18
|
-
stringValue: string;
|
|
19
|
-
};
|
|
20
|
-
attributes?: IKeyValue[];
|
|
21
|
-
traceId?: string;
|
|
22
|
-
spanId?: string;
|
|
23
|
-
}
|
|
24
|
-
export interface ResourceLog {
|
|
25
|
-
resource: Resource;
|
|
26
|
-
scopeLogs: ScopeLog[];
|
|
27
|
-
}
|
|
28
|
-
export type LogTransportItem = TransportItem<Exclude<APIEvent, 'TraceEvent'>>;
|