Skip to content

Commit

Permalink
Merge branch 'main' into span-add-links-after-creation
Browse files Browse the repository at this point in the history
  • Loading branch information
seemk authored May 4, 2024
2 parents 7006fbd + 1c5de7a commit a0047d3
Show file tree
Hide file tree
Showing 76 changed files with 931 additions and 564 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/

* feat(instrumentation): generic config type in instrumentation base [#4659](https://github.com/open-telemetry/opentelemetry-js/pull/4659) @blumamir
* feat: support node 22 [#4666](https://github.com/open-telemetry/opentelemetry-js/pull/4666) @dyladan
* feat(sdk-trace-node): support `xray` Propagator via `OTEL_PROPAGATORS` environment variable [#4602](https://github.com/open-telemetry/opentelemetry-js/pull/4602) @anuraags

### :bug: (Bug Fix)

Expand Down
7 changes: 7 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ All notable changes to experimental packages in this project will be documented
* (user-facing) `convert()` now returns an empty object and will be removed in a follow-up
* (internal) OTLPExporterNodeBase now has additional constructor parameters that are required
* (internal) OTLPExporterNodeBase now has an additional `ResponseType` type parameter
* feat(exporter-*-otlp-*)!: move serialization for Node.js exporters to `@opentelemetry/otlp-transformer` [#4581](https://github.com/open-telemetry/opentelemetry-js/pull/4581) @pichlermarc
* Breaking changes:
* (user-facing) `convert()` has been removed from all exporters
* (internal) OTLPExporterBrowserBase: `RequestType` has been replaced by a `ResponseType` type-argument
* (internal) OTLPExporterNodeBase: `ServiceRequest` has been replaced by a `ServiceResponse` type-argument
* (internal) the `@opentelemetry/otlp-exporter-proto-base` package has been removed, and will from now on be deprecated in `npm`

### :rocket: (Enhancement)

* feat: support node 22 [#4666](https://github.com/open-telemetry/opentelemetry-js/pull/4666) @dyladan
* feat(propagator-aws-xray-lambda): add AWS Xray Lambda propagator [4554](https://github.com/open-telemetry/opentelemetry-js/pull/4554)

### :bug: (Bug Fix)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
DEFAULT_COLLECTOR_URL,
} from '@opentelemetry/otlp-grpc-exporter-base';
import {
IExportLogsServiceRequest,
IExportLogsServiceResponse,
ProtobufLogsSerializer,
} from '@opentelemetry/otlp-transformer';
Expand All @@ -39,7 +38,6 @@ const USER_AGENT = {
export class OTLPLogExporter
extends OTLPGRPCExporterNodeBase<
ReadableLogRecord,
IExportLogsServiceRequest,
IExportLogsServiceResponse
>
implements LogRecordExporter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,30 @@ import type {
LogRecordExporter,
} from '@opentelemetry/sdk-logs';
import type { OTLPExporterConfigBase } from '@opentelemetry/otlp-exporter-base';
import type { IExportLogsServiceRequest } from '@opentelemetry/otlp-transformer';
import type { IExportLogsServiceResponse } from '@opentelemetry/otlp-transformer';
import { OTLPExporterBrowserBase } from '@opentelemetry/otlp-exporter-base';
import { baggageUtils, getEnv } from '@opentelemetry/core';
import { createExportLogsServiceRequest } from '@opentelemetry/otlp-transformer';
import { JsonLogsSerializer } from '@opentelemetry/otlp-transformer';

import { getDefaultUrl } from '../config';

/**
* Collector Logs Exporter for Web
*/
export class OTLPLogExporter
extends OTLPExporterBrowserBase<ReadableLogRecord, IExportLogsServiceRequest>
extends OTLPExporterBrowserBase<ReadableLogRecord, IExportLogsServiceResponse>
implements LogRecordExporter
{
constructor(config: OTLPExporterConfigBase = {}) {
// load OTEL_EXPORTER_OTLP_LOGS_TIMEOUT env var
super({
timeoutMillis: getEnv().OTEL_EXPORTER_OTLP_LOGS_TIMEOUT,
...config,
});
super(
{
timeoutMillis: getEnv().OTEL_EXPORTER_OTLP_LOGS_TIMEOUT,
...config,
},
JsonLogsSerializer,
'application/json'
);
this._headers = {
...this._headers,
...baggageUtils.parseKeyPairsIntoRecord(
Expand All @@ -47,13 +51,6 @@ export class OTLPLogExporter
};
}

convert(logRecords: ReadableLogRecord[]): IExportLogsServiceRequest {
return createExportLogsServiceRequest(logRecords, {
useHex: true,
useLongBits: false,
});
}

getDefaultUrl(config: OTLPExporterConfigBase): string {
return getDefaultUrl(config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ import type {
LogRecordExporter,
} from '@opentelemetry/sdk-logs';
import type { OTLPExporterNodeConfigBase } from '@opentelemetry/otlp-exporter-base';
import type {
IExportLogsServiceRequest,
IExportLogsServiceResponse,
} from '@opentelemetry/otlp-transformer';
import type { IExportLogsServiceResponse } from '@opentelemetry/otlp-transformer';
import { getEnv, baggageUtils } from '@opentelemetry/core';
import {
OTLPExporterNodeBase,
Expand All @@ -41,11 +38,7 @@ const USER_AGENT = {
* Collector Logs Exporter for Node
*/
export class OTLPLogExporter
extends OTLPExporterNodeBase<
ReadableLogRecord,
IExportLogsServiceRequest,
IExportLogsServiceResponse
>
extends OTLPExporterNodeBase<ReadableLogRecord, IExportLogsServiceResponse>
implements LogRecordExporter
{
constructor(config: OTLPExporterNodeConfigBase = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
"@opentelemetry/api-logs": "0.51.0",
"@opentelemetry/core": "1.24.0",
"@opentelemetry/otlp-exporter-base": "0.51.0",
"@opentelemetry/otlp-proto-exporter-base": "0.51.0",
"@opentelemetry/otlp-transformer": "0.51.0",
"@opentelemetry/resources": "1.24.0",
"@opentelemetry/sdk-logs": "0.51.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@ import {
OTLPExporterConfigBase,
appendResourcePathToUrl,
appendRootPathToUrlIfNeeded,
OTLPExporterBrowserBase,
} from '@opentelemetry/otlp-exporter-base';
import {
OTLPProtoExporterBrowserBase,
ServiceClientType,
} from '@opentelemetry/otlp-proto-exporter-base';
import {
createExportLogsServiceRequest,
IExportLogsServiceRequest,
IExportLogsServiceResponse,
ProtobufLogsSerializer,
} from '@opentelemetry/otlp-transformer';

import { ReadableLogRecord, LogRecordExporter } from '@opentelemetry/sdk-logs';
Expand All @@ -38,24 +35,18 @@ const DEFAULT_COLLECTOR_URL = `http://localhost:4318/${DEFAULT_COLLECTOR_RESOURC
* Collector Trace Exporter for Web
*/
export class OTLPLogExporter
extends OTLPProtoExporterBrowserBase<
ReadableLogRecord,
IExportLogsServiceRequest
>
extends OTLPExporterBrowserBase<ReadableLogRecord, IExportLogsServiceResponse>
implements LogRecordExporter
{
constructor(config: OTLPExporterConfigBase = {}) {
super(config);
super(config, ProtobufLogsSerializer, 'application/x-protobuf');
this._headers = Object.assign(
this._headers,
baggageUtils.parseKeyPairsIntoRecord(
getEnv().OTEL_EXPORTER_OTLP_LOGS_HEADERS
)
);
}
convert(logs: ReadableLogRecord[]): IExportLogsServiceRequest {
return createExportLogsServiceRequest(logs);
}

getDefaultUrl(config: OTLPExporterConfigBase): string {
return typeof config.url === 'string'
Expand All @@ -69,8 +60,4 @@ export class OTLPLogExporter
)
: DEFAULT_COLLECTOR_URL;
}

getServiceClientType() {
return ServiceClientType.LOGS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ import {
OTLPExporterNodeBase,
parseHeaders,
} from '@opentelemetry/otlp-exporter-base';
import { ServiceClientType } from '@opentelemetry/otlp-proto-exporter-base';
import {
IExportLogsServiceRequest,
IExportLogsServiceResponse,
ProtobufLogsSerializer,
} from '@opentelemetry/otlp-transformer';
Expand All @@ -43,11 +41,7 @@ const DEFAULT_COLLECTOR_URL = `http://localhost:4318/${DEFAULT_COLLECTOR_RESOURC
* Collector Trace Exporter for Node
*/
export class OTLPLogExporter
extends OTLPExporterNodeBase<
ReadableLogRecord,
IExportLogsServiceRequest,
IExportLogsServiceResponse
>
extends OTLPExporterNodeBase<ReadableLogRecord, IExportLogsServiceResponse>
implements LogRecordExporter
{
constructor(config: OTLPExporterConfigBase = {}) {
Expand All @@ -74,8 +68,4 @@ export class OTLPLogExporter
)
: DEFAULT_COLLECTOR_URL;
}

getServiceClientType() {
return ServiceClientType.LOGS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,27 @@ import {
OTLPExporterNodeConfigBase,
OTLPExporterError,
} from '@opentelemetry/otlp-exporter-base';
import {
getExportRequestProto,
ServiceClientType,
} from '@opentelemetry/otlp-proto-exporter-base';
import { IExportLogsServiceRequest } from '@opentelemetry/otlp-transformer';
import { ReadableLogRecord } from '@opentelemetry/sdk-logs';
import { VERSION } from '../../src/version';
import { Root } from 'protobufjs';
import * as path from 'path';

let fakeRequest: PassThrough;

const dir = path.resolve(__dirname, '../../../otlp-transformer/protos');
const root = new Root();
root.resolvePath = function (origin, target) {
return `${dir}/${target}`;
};
const proto = root.loadSync([
'opentelemetry/proto/common/v1/common.proto',
'opentelemetry/proto/resource/v1/resource.proto',
'opentelemetry/proto/logs/v1/logs.proto',
'opentelemetry/proto/collector/logs/v1/logs_service.proto',
]);
const exportRequestServiceProto = proto?.lookupType('ExportLogsServiceRequest');

describe('OTLPLogExporter - node with proto over http', () => {
let collectorExporter: OTLPLogExporter;
let collectorExporterConfig: OTLPExporterNodeConfigBase;
Expand Down Expand Up @@ -240,10 +251,7 @@ describe('OTLPLogExporter - node with proto over http', () => {

let buff = Buffer.from('');
fakeRequest.on('end', () => {
const ExportLogsServiceRequestProto = getExportRequestProto(
ServiceClientType.LOGS
);
const data = ExportLogsServiceRequestProto.decode(buff);
const data = exportRequestServiceProto.decode(buff);
const json = data?.toJSON() as IExportLogsServiceRequest;
const log1 = json.resourceLogs?.[0].scopeLogs?.[0].logRecords?.[0];
assert.ok(typeof log1 !== 'undefined', "log doesn't exist");
Expand Down Expand Up @@ -328,10 +336,7 @@ describe('OTLPLogExporter - node with proto over http', () => {
let buff = Buffer.from('');
fakeRequest.on('end', () => {
const unzippedBuff = zlib.gunzipSync(buff);
const ExportLogsServiceRequestProto = getExportRequestProto(
ServiceClientType.LOGS
);
const data = ExportLogsServiceRequestProto.decode(unzippedBuff);
const data = exportRequestServiceProto.decode(unzippedBuff);
const json = data?.toJSON() as IExportLogsServiceRequest;
const log1 = json.resourceLogs?.[0].scopeLogs?.[0].logRecords?.[0];
assert.ok(typeof log1 !== 'undefined', "log doesn't exist");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
{
"path": "../otlp-exporter-base"
},
{
"path": "../otlp-proto-exporter-base"
},
{
"path": "../otlp-transformer"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
{
"path": "../otlp-exporter-base"
},
{
"path": "../otlp-proto-exporter-base"
},
{
"path": "../otlp-transformer"
},
Expand Down
3 changes: 0 additions & 3 deletions experimental/packages/exporter-logs-otlp-proto/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
{
"path": "../otlp-exporter-base"
},
{
"path": "../otlp-proto-exporter-base"
},
{
"path": "../otlp-transformer"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
DEFAULT_COLLECTOR_URL,
} from '@opentelemetry/otlp-grpc-exporter-base';
import {
IExportTraceServiceRequest,
IExportTraceServiceResponse,
ProtobufTraceSerializer,
} from '@opentelemetry/otlp-transformer';
Expand All @@ -37,11 +36,7 @@ const USER_AGENT = {
* OTLP Trace Exporter for Node
*/
export class OTLPTraceExporter
extends OTLPGRPCExporterNodeBase<
ReadableSpan,
IExportTraceServiceRequest,
IExportTraceServiceResponse
>
extends OTLPGRPCExporterNodeBase<ReadableSpan, IExportTraceServiceResponse>
implements SpanExporter
{
constructor(config: OTLPGRPCExporterConfigNode = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
OTLPExporterBrowserBase,
} from '@opentelemetry/otlp-exporter-base';
import {
createExportTraceServiceRequest,
IExportTraceServiceRequest,
IExportTraceServiceResponse,
JsonTraceSerializer,
} from '@opentelemetry/otlp-transformer';

const DEFAULT_COLLECTOR_RESOURCE_PATH = 'v1/traces';
Expand All @@ -34,24 +34,18 @@ const DEFAULT_COLLECTOR_URL = `http://localhost:4318/${DEFAULT_COLLECTOR_RESOURC
* Collector Trace Exporter for Web
*/
export class OTLPTraceExporter
extends OTLPExporterBrowserBase<ReadableSpan, IExportTraceServiceRequest>
extends OTLPExporterBrowserBase<ReadableSpan, IExportTraceServiceResponse>
implements SpanExporter
{
constructor(config: OTLPExporterConfigBase = {}) {
super(config);
super(config, JsonTraceSerializer, 'application/json');
this._headers = Object.assign(
this._headers,
baggageUtils.parseKeyPairsIntoRecord(
getEnv().OTEL_EXPORTER_OTLP_TRACES_HEADERS
)
);
}
convert(spans: ReadableSpan[]): IExportTraceServiceRequest {
return createExportTraceServiceRequest(spans, {
useHex: true,
useLongBits: false,
});
}

getDefaultUrl(config: OTLPExporterConfigBase): string {
return typeof config.url === 'string'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ import {
appendResourcePathToUrl,
appendRootPathToUrlIfNeeded,
} from '@opentelemetry/otlp-exporter-base';
import {
IExportTraceServiceRequest,
IExportTraceServiceResponse,
} from '@opentelemetry/otlp-transformer';
import { IExportTraceServiceResponse } from '@opentelemetry/otlp-transformer';
import { VERSION } from '../../version';
import { JsonTraceSerializer } from '@opentelemetry/otlp-transformer';

Expand All @@ -42,11 +39,7 @@ const USER_AGENT = {
* Collector Trace Exporter for Node
*/
export class OTLPTraceExporter
extends OTLPExporterNodeBase<
ReadableSpan,
IExportTraceServiceRequest,
IExportTraceServiceResponse
>
extends OTLPExporterNodeBase<ReadableSpan, IExportTraceServiceResponse>
implements SpanExporter
{
constructor(config: OTLPExporterNodeConfigBase = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ describe('OTLPTraceExporter - web', () => {
assert.strictEqual(request.url, 'http://foo.bar.com');

const body = request.requestBody;
const json = JSON.parse(body) as IExportTraceServiceRequest;
const decoder = new TextDecoder();
const json = JSON.parse(
decoder.decode(body)
) as IExportTraceServiceRequest;
const span1 = json.resourceSpans?.[0].scopeSpans?.[0].spans?.[0];

assert.ok(typeof span1 !== 'undefined', "span doesn't exist");
Expand Down
Loading

0 comments on commit a0047d3

Please sign in to comment.