diff --git a/examples/collector-exporter-node/docker/docker-compose.yaml b/examples/collector-exporter-node/docker/docker-compose.yaml index e93b603c49..14ceeaf00e 100644 --- a/examples/collector-exporter-node/docker/docker-compose.yaml +++ b/examples/collector-exporter-node/docker/docker-compose.yaml @@ -2,7 +2,7 @@ version: "3" services: # Collector collector: - image: otel/opentelemetry-collector:0.13.0 + image: otel/opentelemetry-collector:0.16.0 # image: otel/opentelemetry-collector:latest command: ["--config=/conf/collector-config.yaml", "--log-level=DEBUG"] volumes: diff --git a/packages/opentelemetry-exporter-collector-grpc/protos b/packages/opentelemetry-exporter-collector-grpc/protos index 313a868be2..59c488bfb8 160000 --- a/packages/opentelemetry-exporter-collector-grpc/protos +++ b/packages/opentelemetry-exporter-collector-grpc/protos @@ -1 +1 @@ -Subproject commit 313a868be259dce6c6516dd417d3ad5fd3321acf +Subproject commit 59c488bfb8fb6d0458ad6425758b70259ff4a2bd diff --git a/packages/opentelemetry-exporter-collector-grpc/test/helper.ts b/packages/opentelemetry-exporter-collector-grpc/test/helper.ts index a45eecff16..a425e5de93 100644 --- a/packages/opentelemetry-exporter-collector-grpc/test/helper.ts +++ b/packages/opentelemetry-exporter-collector-grpc/test/helper.ts @@ -308,7 +308,11 @@ export function ensureExportedSpanIsCorrect( assert.strictEqual(span.droppedLinksCount, 0, 'droppedLinksCount is wrong'); assert.deepStrictEqual( span.status, - { code: 'STATUS_CODE_OK', message: '' }, + { + code: 'STATUS_CODE_OK', + deprecatedCode: 'DEPRECATED_STATUS_CODE_OK', + message: '', + }, 'status is wrong' ); } diff --git a/packages/opentelemetry-exporter-collector-proto/protos b/packages/opentelemetry-exporter-collector-proto/protos index 313a868be2..59c488bfb8 160000 --- a/packages/opentelemetry-exporter-collector-proto/protos +++ b/packages/opentelemetry-exporter-collector-proto/protos @@ -1 +1 @@ -Subproject commit 313a868be259dce6c6516dd417d3ad5fd3321acf +Subproject commit 59c488bfb8fb6d0458ad6425758b70259ff4a2bd diff --git a/packages/opentelemetry-exporter-collector/README.md b/packages/opentelemetry-exporter-collector/README.md index 473f7b6261..1d0cf969d9 100644 --- a/packages/opentelemetry-exporter-collector/README.md +++ b/packages/opentelemetry-exporter-collector/README.md @@ -6,7 +6,7 @@ [![devDependencies][devDependencies-image]][devDependencies-url] [![Apache License][license-image]][license-image] -This module provides exporter for web and node to be used with [opentelemetry-collector][opentelemetry-collector-url] - last tested with version **0.12.0**. +This module provides exporter for web and node to be used with [opentelemetry-collector][opentelemetry-collector-url] - last tested with version **0.16.0**. ## Installation diff --git a/packages/opentelemetry-exporter-collector/src/transform.ts b/packages/opentelemetry-exporter-collector/src/transform.ts index ed0d4cdcfa..090ad496be 100644 --- a/packages/opentelemetry-exporter-collector/src/transform.ts +++ b/packages/opentelemetry-exporter-collector/src/transform.ts @@ -18,6 +18,8 @@ import { Attributes, Link, SpanKind, + Status, + StatusCode, TimedEvent, TraceState, } from '@opentelemetry/api'; @@ -184,12 +186,45 @@ export function toCollectorSpan( droppedAttributesCount: 0, events: toCollectorEvents(span.events), droppedEventsCount: 0, - status: span.status, + status: toCollectorStatus(span.status), links: toCollectorLinks(span, useHex), droppedLinksCount: 0, }; } +/** + * Converts StatusCode + * @param code + */ +export function toCollectorCode( + code: StatusCode +): opentelemetryProto.trace.v1.StatusCode { + switch (code) { + case StatusCode.OK: + return opentelemetryProto.trace.v1.StatusCode.OK; + case StatusCode.UNSET: + return opentelemetryProto.trace.v1.StatusCode.UNSET; + default: + return opentelemetryProto.trace.v1.StatusCode.ERROR; + } +} + +/** + * Converts status + * @param status + */ +export function toCollectorStatus( + status: Status +): opentelemetryProto.trace.v1.Status { + const spanStatus: opentelemetryProto.trace.v1.Status = { + code: toCollectorCode(status.code), + }; + if (typeof status.message !== 'undefined') { + spanStatus.message = status.message; + } + return spanStatus; +} + /** * Converts resource * @param resource diff --git a/packages/opentelemetry-exporter-collector/src/types.ts b/packages/opentelemetry-exporter-collector/src/types.ts index ab6423b8f9..2c82aa8813 100644 --- a/packages/opentelemetry-exporter-collector/src/types.ts +++ b/packages/opentelemetry-exporter-collector/src/types.ts @@ -15,7 +15,6 @@ */ import { SpanKind, Logger, Attributes } from '@opentelemetry/api'; -import * as api from '@opentelemetry/api'; /* eslint-disable @typescript-eslint/no-namespace */ export namespace opentelemetryProto { @@ -254,7 +253,32 @@ export namespace opentelemetryProto { status?: Status; } - export type Status = api.Status; + export interface Status { + /** The status code of this message. */ + code: StatusCode; + /** A developer-facing error message. */ + message?: string; + } + + /** + * An enumeration of status codes. + * https://github.com/open-telemetry/opentelemetry-proto/blob/master/opentelemetry/proto/trace/v1/trace.proto#L304 + */ + export enum StatusCode { + /** + * The default status. + */ + UNSET = 0, + /** + * The operation has been validated by an Application developer or + * Operator to have completed successfully. + */ + OK = 1, + /** + * The operation contains an error. + */ + ERROR = 2, + } export interface TraceConfig { constantSampler?: ConstantSampler | null; diff --git a/packages/opentelemetry-exporter-collector/test/helper.ts b/packages/opentelemetry-exporter-collector/test/helper.ts index b451bd1443..1d45c2dfaf 100644 --- a/packages/opentelemetry-exporter-collector/test/helper.ts +++ b/packages/opentelemetry-exporter-collector/test/helper.ts @@ -507,7 +507,7 @@ export function ensureSpanIsCorrect( assert.strictEqual(span.droppedLinksCount, 0, 'droppedLinksCount is wrong'); assert.deepStrictEqual( span.status, - { code: api.StatusCode.OK }, + { code: opentelemetryProto.trace.v1.StatusCode.OK }, 'status is wrong' ); }