@opentelemetry/otlp-transformer
Advanced tools
Comparing version
@@ -1,3 +0,5 @@ | ||
import type { IAnyValue, IKeyValue } from './types'; | ||
import type { IAnyValue, IInstrumentationScope, IKeyValue } from './types'; | ||
import { Attributes } from '@opentelemetry/api'; | ||
import { InstrumentationScope } from '@opentelemetry/core'; | ||
export declare function createInstrumentationScope(scope: InstrumentationScope): IInstrumentationScope; | ||
export declare function toAttributes(attributes: Attributes): IKeyValue[]; | ||
@@ -4,0 +6,0 @@ export declare function toKeyValue(key: string, value: unknown): IKeyValue; |
@@ -17,2 +17,8 @@ var __read = (this && this.__read) || function (o, n) { | ||
}; | ||
export function createInstrumentationScope(scope) { | ||
return { | ||
name: scope.name, | ||
version: scope.version, | ||
}; | ||
} | ||
export function toAttributes(attributes) { | ||
@@ -19,0 +25,0 @@ return Object.keys(attributes).map(function (key) { return toKeyValue(key, attributes[key]); }); |
@@ -44,3 +44,4 @@ /* | ||
import { getOtlpEncoder } from '../common'; | ||
import { toAnyValue, toAttributes, toKeyValue } from '../common/internal'; | ||
import { createInstrumentationScope, toAnyValue, toKeyValue, } from '../common/internal'; | ||
import { createResource } from '../resource/internal'; | ||
export function createExportLogsServiceRequest(logRecords, options) { | ||
@@ -87,13 +88,9 @@ var encoder = getOtlpEncoder(options); | ||
return ({ | ||
resource: { | ||
attributes: toAttributes(resource.attributes), | ||
droppedAttributesCount: 0, | ||
}, | ||
resource: createResource(resource), | ||
scopeLogs: Array.from(ismMap, function (_a) { | ||
var _b = __read(_a, 2), scopeLogs = _b[1]; | ||
var _c = scopeLogs[0].instrumentationScope, name = _c.name, version = _c.version, schemaUrl = _c.schemaUrl; | ||
return { | ||
scope: { name: name, version: version }, | ||
scope: createInstrumentationScope(scopeLogs[0].instrumentationScope), | ||
logRecords: scopeLogs.map(function (log) { return toLogRecord(log, encoder); }), | ||
schemaUrl: schemaUrl, | ||
schemaUrl: scopeLogs[0].instrumentationScope.schemaUrl, | ||
}; | ||
@@ -100,0 +97,0 @@ }), |
import { ValueType } from '@opentelemetry/api'; | ||
import { AggregationTemporality, DataPointType, } from '@opentelemetry/sdk-metrics'; | ||
import { toAttributes } from '../common/internal'; | ||
import { getOtlpEncoder } from '../common'; | ||
import { createInstrumentationScope, toAttributes } from '../common/internal'; | ||
import { createResource } from '../resource/internal'; | ||
export function toResourceMetrics(resourceMetrics, options) { | ||
var encoder = getOtlpEncoder(options); | ||
return { | ||
resource: { | ||
attributes: toAttributes(resourceMetrics.resource.attributes), | ||
droppedAttributesCount: 0, | ||
}, | ||
resource: createResource(resourceMetrics.resource), | ||
schemaUrl: undefined, | ||
@@ -18,6 +16,3 @@ scopeMetrics: toScopeMetrics(resourceMetrics.scopeMetrics, encoder), | ||
return Array.from(scopeMetrics.map(function (metrics) { return ({ | ||
scope: { | ||
name: metrics.scope.name, | ||
version: metrics.scope.version, | ||
}, | ||
scope: createInstrumentationScope(metrics.scope), | ||
metrics: metrics.metrics.map(function (metricData) { return toMetric(metricData, encoder); }), | ||
@@ -24,0 +19,0 @@ schemaUrl: metrics.scope.schemaUrl, |
@@ -28,5 +28,6 @@ var __values = (this && this.__values) || function(o) { | ||
}; | ||
import { toAttributes } from '../common/internal'; | ||
import { sdkSpanToOtlpSpan } from './internal'; | ||
import { getOtlpEncoder } from '../common'; | ||
import { createInstrumentationScope } from '../common/internal'; | ||
import { createResource } from '../resource/internal'; | ||
export function createExportTraceServiceRequest(spans, options) { | ||
@@ -81,3 +82,2 @@ var encoder = getOtlpEncoder(options); | ||
if (scopeSpans.length > 0) { | ||
var _b = scopeSpans[0].instrumentationLibrary, name_1 = _b.name, version = _b.version, schemaUrl = _b.schemaUrl; | ||
var spans = scopeSpans.map(function (readableSpan) { | ||
@@ -87,5 +87,5 @@ return sdkSpanToOtlpSpan(readableSpan, encoder); | ||
scopeResourceSpans.push({ | ||
scope: { name: name_1, version: version }, | ||
scope: createInstrumentationScope(scopeSpans[0].instrumentationLibrary), | ||
spans: spans, | ||
schemaUrl: schemaUrl, | ||
schemaUrl: scopeSpans[0].instrumentationLibrary.schemaUrl, | ||
}); | ||
@@ -97,6 +97,3 @@ } | ||
var transformedSpans = { | ||
resource: { | ||
attributes: toAttributes(resource.attributes), | ||
droppedAttributesCount: 0, | ||
}, | ||
resource: createResource(resource), | ||
scopeSpans: scopeResourceSpans, | ||
@@ -103,0 +100,0 @@ schemaUrl: undefined, |
@@ -1,3 +0,5 @@ | ||
import type { IAnyValue, IKeyValue } from './types'; | ||
import type { IAnyValue, IInstrumentationScope, IKeyValue } from './types'; | ||
import { Attributes } from '@opentelemetry/api'; | ||
import { InstrumentationScope } from '@opentelemetry/core'; | ||
export declare function createInstrumentationScope(scope: InstrumentationScope): IInstrumentationScope; | ||
export declare function toAttributes(attributes: Attributes): IKeyValue[]; | ||
@@ -4,0 +6,0 @@ export declare function toKeyValue(key: string, value: unknown): IKeyValue; |
@@ -0,1 +1,7 @@ | ||
export function createInstrumentationScope(scope) { | ||
return { | ||
name: scope.name, | ||
version: scope.version, | ||
}; | ||
} | ||
export function toAttributes(attributes) { | ||
@@ -2,0 +8,0 @@ return Object.keys(attributes).map(key => toKeyValue(key, attributes[key])); |
@@ -17,3 +17,4 @@ /* | ||
import { getOtlpEncoder } from '../common'; | ||
import { toAnyValue, toAttributes, toKeyValue } from '../common/internal'; | ||
import { createInstrumentationScope, toAnyValue, toKeyValue, } from '../common/internal'; | ||
import { createResource } from '../resource/internal'; | ||
export function createExportLogsServiceRequest(logRecords, options) { | ||
@@ -47,12 +48,8 @@ const encoder = getOtlpEncoder(options); | ||
return Array.from(resourceMap, ([resource, ismMap]) => ({ | ||
resource: { | ||
attributes: toAttributes(resource.attributes), | ||
droppedAttributesCount: 0, | ||
}, | ||
resource: createResource(resource), | ||
scopeLogs: Array.from(ismMap, ([, scopeLogs]) => { | ||
const { instrumentationScope: { name, version, schemaUrl }, } = scopeLogs[0]; | ||
return { | ||
scope: { name, version }, | ||
scope: createInstrumentationScope(scopeLogs[0].instrumentationScope), | ||
logRecords: scopeLogs.map(log => toLogRecord(log, encoder)), | ||
schemaUrl, | ||
schemaUrl: scopeLogs[0].instrumentationScope.schemaUrl, | ||
}; | ||
@@ -59,0 +56,0 @@ }), |
import { ValueType } from '@opentelemetry/api'; | ||
import { AggregationTemporality, DataPointType, } from '@opentelemetry/sdk-metrics'; | ||
import { toAttributes } from '../common/internal'; | ||
import { getOtlpEncoder } from '../common'; | ||
import { createInstrumentationScope, toAttributes } from '../common/internal'; | ||
import { createResource } from '../resource/internal'; | ||
export function toResourceMetrics(resourceMetrics, options) { | ||
const encoder = getOtlpEncoder(options); | ||
return { | ||
resource: { | ||
attributes: toAttributes(resourceMetrics.resource.attributes), | ||
droppedAttributesCount: 0, | ||
}, | ||
resource: createResource(resourceMetrics.resource), | ||
schemaUrl: undefined, | ||
@@ -18,6 +16,3 @@ scopeMetrics: toScopeMetrics(resourceMetrics.scopeMetrics, encoder), | ||
return Array.from(scopeMetrics.map(metrics => ({ | ||
scope: { | ||
name: metrics.scope.name, | ||
version: metrics.scope.version, | ||
}, | ||
scope: createInstrumentationScope(metrics.scope), | ||
metrics: metrics.metrics.map(metricData => toMetric(metricData, encoder)), | ||
@@ -24,0 +19,0 @@ schemaUrl: metrics.scope.schemaUrl, |
@@ -1,4 +0,5 @@ | ||
import { toAttributes } from '../common/internal'; | ||
import { sdkSpanToOtlpSpan } from './internal'; | ||
import { getOtlpEncoder } from '../common'; | ||
import { createInstrumentationScope } from '../common/internal'; | ||
import { createResource } from '../resource/internal'; | ||
export function createExportTraceServiceRequest(spans, options) { | ||
@@ -42,8 +43,7 @@ const encoder = getOtlpEncoder(options); | ||
if (scopeSpans.length > 0) { | ||
const { name, version, schemaUrl } = scopeSpans[0].instrumentationLibrary; | ||
const spans = scopeSpans.map(readableSpan => sdkSpanToOtlpSpan(readableSpan, encoder)); | ||
scopeResourceSpans.push({ | ||
scope: { name, version }, | ||
scope: createInstrumentationScope(scopeSpans[0].instrumentationLibrary), | ||
spans: spans, | ||
schemaUrl: schemaUrl, | ||
schemaUrl: scopeSpans[0].instrumentationLibrary.schemaUrl, | ||
}); | ||
@@ -55,6 +55,3 @@ } | ||
const transformedSpans = { | ||
resource: { | ||
attributes: toAttributes(resource.attributes), | ||
droppedAttributesCount: 0, | ||
}, | ||
resource: createResource(resource), | ||
scopeSpans: scopeResourceSpans, | ||
@@ -61,0 +58,0 @@ schemaUrl: undefined, |
@@ -1,3 +0,5 @@ | ||
import type { IAnyValue, IKeyValue } from './types'; | ||
import type { IAnyValue, IInstrumentationScope, IKeyValue } from './types'; | ||
import { Attributes } from '@opentelemetry/api'; | ||
import { InstrumentationScope } from '@opentelemetry/core'; | ||
export declare function createInstrumentationScope(scope: InstrumentationScope): IInstrumentationScope; | ||
export declare function toAttributes(attributes: Attributes): IKeyValue[]; | ||
@@ -4,0 +6,0 @@ export declare function toKeyValue(key: string, value: unknown): IKeyValue; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toAnyValue = exports.toKeyValue = exports.toAttributes = void 0; | ||
exports.toAnyValue = exports.toKeyValue = exports.toAttributes = exports.createInstrumentationScope = void 0; | ||
function createInstrumentationScope(scope) { | ||
return { | ||
name: scope.name, | ||
version: scope.version, | ||
}; | ||
} | ||
exports.createInstrumentationScope = createInstrumentationScope; | ||
function toAttributes(attributes) { | ||
@@ -5,0 +12,0 @@ return Object.keys(attributes).map(key => toKeyValue(key, attributes[key])); |
@@ -21,2 +21,3 @@ "use strict"; | ||
const internal_1 = require("../common/internal"); | ||
const internal_2 = require("../resource/internal"); | ||
function createExportLogsServiceRequest(logRecords, options) { | ||
@@ -51,12 +52,8 @@ const encoder = (0, common_1.getOtlpEncoder)(options); | ||
return Array.from(resourceMap, ([resource, ismMap]) => ({ | ||
resource: { | ||
attributes: (0, internal_1.toAttributes)(resource.attributes), | ||
droppedAttributesCount: 0, | ||
}, | ||
resource: (0, internal_2.createResource)(resource), | ||
scopeLogs: Array.from(ismMap, ([, scopeLogs]) => { | ||
const { instrumentationScope: { name, version, schemaUrl }, } = scopeLogs[0]; | ||
return { | ||
scope: { name, version }, | ||
scope: (0, internal_1.createInstrumentationScope)(scopeLogs[0].instrumentationScope), | ||
logRecords: scopeLogs.map(log => toLogRecord(log, encoder)), | ||
schemaUrl, | ||
schemaUrl: scopeLogs[0].instrumentationScope.schemaUrl, | ||
}; | ||
@@ -63,0 +60,0 @@ }), |
@@ -6,11 +6,9 @@ "use strict"; | ||
const sdk_metrics_1 = require("@opentelemetry/sdk-metrics"); | ||
const common_1 = require("../common"); | ||
const internal_1 = require("../common/internal"); | ||
const common_1 = require("../common"); | ||
const internal_2 = require("../resource/internal"); | ||
function toResourceMetrics(resourceMetrics, options) { | ||
const encoder = (0, common_1.getOtlpEncoder)(options); | ||
return { | ||
resource: { | ||
attributes: (0, internal_1.toAttributes)(resourceMetrics.resource.attributes), | ||
droppedAttributesCount: 0, | ||
}, | ||
resource: (0, internal_2.createResource)(resourceMetrics.resource), | ||
schemaUrl: undefined, | ||
@@ -23,6 +21,3 @@ scopeMetrics: toScopeMetrics(resourceMetrics.scopeMetrics, encoder), | ||
return Array.from(scopeMetrics.map(metrics => ({ | ||
scope: { | ||
name: metrics.scope.name, | ||
version: metrics.scope.version, | ||
}, | ||
scope: (0, internal_1.createInstrumentationScope)(metrics.scope), | ||
metrics: metrics.metrics.map(metricData => toMetric(metricData, encoder)), | ||
@@ -29,0 +24,0 @@ schemaUrl: metrics.scope.schemaUrl, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createExportTraceServiceRequest = void 0; | ||
const internal_1 = require("../common/internal"); | ||
const internal_2 = require("./internal"); | ||
const internal_1 = require("./internal"); | ||
const common_1 = require("../common"); | ||
const internal_2 = require("../common/internal"); | ||
const internal_3 = require("../resource/internal"); | ||
function createExportTraceServiceRequest(spans, options) { | ||
@@ -46,8 +47,7 @@ const encoder = (0, common_1.getOtlpEncoder)(options); | ||
if (scopeSpans.length > 0) { | ||
const { name, version, schemaUrl } = scopeSpans[0].instrumentationLibrary; | ||
const spans = scopeSpans.map(readableSpan => (0, internal_2.sdkSpanToOtlpSpan)(readableSpan, encoder)); | ||
const spans = scopeSpans.map(readableSpan => (0, internal_1.sdkSpanToOtlpSpan)(readableSpan, encoder)); | ||
scopeResourceSpans.push({ | ||
scope: { name, version }, | ||
scope: (0, internal_2.createInstrumentationScope)(scopeSpans[0].instrumentationLibrary), | ||
spans: spans, | ||
schemaUrl: schemaUrl, | ||
schemaUrl: scopeSpans[0].instrumentationLibrary.schemaUrl, | ||
}); | ||
@@ -59,6 +59,3 @@ } | ||
const transformedSpans = { | ||
resource: { | ||
attributes: (0, internal_1.toAttributes)(resource.attributes), | ||
droppedAttributesCount: 0, | ||
}, | ||
resource: (0, internal_3.createResource)(resource), | ||
scopeSpans: scopeResourceSpans, | ||
@@ -65,0 +62,0 @@ schemaUrl: undefined, |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "0.50.0", | ||
"version": "0.51.0", | ||
"description": "Transform OpenTelemetry SDK data into OTLP", | ||
@@ -83,12 +83,12 @@ "module": "build/esm/index.js", | ||
"dependencies": { | ||
"@opentelemetry/api-logs": "0.50.0", | ||
"@opentelemetry/core": "1.23.0", | ||
"@opentelemetry/resources": "1.23.0", | ||
"@opentelemetry/sdk-logs": "0.50.0", | ||
"@opentelemetry/sdk-metrics": "1.23.0", | ||
"@opentelemetry/sdk-trace-base": "1.23.0" | ||
"@opentelemetry/api-logs": "0.51.0", | ||
"@opentelemetry/core": "1.24.0", | ||
"@opentelemetry/resources": "1.24.0", | ||
"@opentelemetry/sdk-logs": "0.51.0", | ||
"@opentelemetry/sdk-metrics": "1.24.0", | ||
"@opentelemetry/sdk-trace-base": "1.24.0" | ||
}, | ||
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/otlp-transformer", | ||
"sideEffects": false, | ||
"gitHead": "5231aa255047fbc6ee3d6a299f4423ab2f8a5fbc" | ||
"gitHead": "3ab4f765d8d696327b7d139ae6a45e7bd7edd924" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
353099
1.89%129
7.5%3656
0.72%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated