Skip to content

Commit

Permalink
feat(otlp-transformer)!: restructure internals to allow for different…
Browse files Browse the repository at this point in the history
… entrypoints
  • Loading branch information
pichlermarc committed Dec 13, 2024
1 parent 6d31a18 commit ebf6beb
Show file tree
Hide file tree
Showing 55 changed files with 838 additions and 523 deletions.
4 changes: 2 additions & 2 deletions .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"exclude": [
"**/*.d.ts",
"build/**/*.*",
"src/index.ts",
"src/platform/**/index.ts",
"src/internal.ts",
"src/platform/**/internal.ts",
"src/version.ts",
"test/**/*.*",
".eslintrc.js",
Expand Down
4 changes: 2 additions & 2 deletions doc/exporter-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ A typical package layout:
```text
opentelemetry-exporter-myexporter
├── src
│ └── index.ts
│ └── internal.ts
│ └── transform.ts
│ └── types.ts
│ └── internal-internal-internal-internal-types.ts
│ └── my-trace-exporter.ts
│ └── my-metric-exporter.ts
└── test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
createOtlpGrpcExportDelegate,
OTLPGRPCExporterConfigNode,
} from '@opentelemetry/otlp-grpc-exporter-base';
import { ProtobufLogsSerializer } from '@opentelemetry/otlp-transformer';
import { ProtobufLogsSerializer } from '@opentelemetry/otlp-transformer/experimental/logs/protobuf';
import { OTLPExporterBase } from '@opentelemetry/otlp-exporter-base';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import type {
} from '@opentelemetry/sdk-logs';
import type { OTLPExporterConfigBase } from '@opentelemetry/otlp-exporter-base';
import { OTLPExporterBase } from '@opentelemetry/otlp-exporter-base';
import { JsonLogsSerializer } from '@opentelemetry/otlp-transformer';
import { createLegacyOtlpBrowserExportDelegate } from '@opentelemetry/otlp-exporter-base/browser-http';
import { JsonLogsSerializer } from '@opentelemetry/otlp-transformer/experimental/logs/json';

/**
* Collector Logs Exporter for Web
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
} from '@opentelemetry/sdk-logs';
import type { OTLPExporterNodeConfigBase } from '@opentelemetry/otlp-exporter-base';
import { OTLPExporterBase } from '@opentelemetry/otlp-exporter-base';
import { JsonLogsSerializer } from '@opentelemetry/otlp-transformer';
import { JsonLogsSerializer } from '@opentelemetry/otlp-transformer/experimental/logs/json';
import { VERSION } from '../../version';
import {
convertLegacyHttpOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
OTLPExporterConfigBase,
OTLPExporterBase,
} from '@opentelemetry/otlp-exporter-base';
import { ProtobufLogsSerializer } from '@opentelemetry/otlp-transformer';
import { ProtobufLogsSerializer } from '@opentelemetry/otlp-transformer/experimental/logs/protobuf';

import { ReadableLogRecord, LogRecordExporter } from '@opentelemetry/sdk-logs';
import { createLegacyOtlpBrowserExportDelegate } from '@opentelemetry/otlp-exporter-base/browser-http';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
OTLPExporterBase,
OTLPExporterNodeConfigBase,
} from '@opentelemetry/otlp-exporter-base';
import { ProtobufLogsSerializer } from '@opentelemetry/otlp-transformer';
import { ProtobufLogsSerializer } from '@opentelemetry/otlp-transformer/experimental/logs/protobuf';
import {
convertLegacyHttpOptions,
createOtlpHttpExportDelegate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
createOtlpGrpcExportDelegate,
OTLPGRPCExporterConfigNode,
} from '@opentelemetry/otlp-grpc-exporter-base';
import { ProtobufTraceSerializer } from '@opentelemetry/otlp-transformer';
import { ProtobufTraceSerializer } from '@opentelemetry/otlp-transformer/trace/protobuf';
import { OTLPExporterBase } from '@opentelemetry/otlp-exporter-base';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
OTLPExporterConfigBase,
OTLPExporterBase,
} from '@opentelemetry/otlp-exporter-base';
import { JsonTraceSerializer } from '@opentelemetry/otlp-transformer';
import { JsonTraceSerializer } from '@opentelemetry/otlp-transformer/trace/json';
import { createLegacyOtlpBrowserExportDelegate } from '@opentelemetry/otlp-exporter-base/browser-http';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
OTLPExporterBase,
} from '@opentelemetry/otlp-exporter-base';
import { VERSION } from '../../version';
import { JsonTraceSerializer } from '@opentelemetry/otlp-transformer';
import { JsonTraceSerializer } from '@opentelemetry/otlp-transformer/trace/json';
import {
convertLegacyHttpOptions,
createOtlpHttpExportDelegate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
OTLPExporterConfigBase,
OTLPExporterBase,
} from '@opentelemetry/otlp-exporter-base';
import { ProtobufTraceSerializer } from '@opentelemetry/otlp-transformer';
import { ProtobufTraceSerializer } from '@opentelemetry/otlp-transformer/trace/protobuf';
import { createLegacyOtlpBrowserExportDelegate } from '@opentelemetry/otlp-exporter-base/browser-http';

const DEFAULT_COLLECTOR_RESOURCE_PATH = 'v1/traces';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
OTLPExporterNodeConfigBase,
OTLPExporterBase,
} from '@opentelemetry/otlp-exporter-base';
import { ProtobufTraceSerializer } from '@opentelemetry/otlp-transformer';
import { ProtobufTraceSerializer } from '@opentelemetry/otlp-transformer/trace/protobuf';
import { VERSION } from '../../version';
import {
createOtlpHttpExportDelegate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
createOtlpGrpcExportDelegate,
OTLPGRPCExporterConfigNode,
} from '@opentelemetry/otlp-grpc-exporter-base';
import { ProtobufMetricsSerializer } from '@opentelemetry/otlp-transformer';
import { ProtobufMetricsSerializer } from '@opentelemetry/otlp-transformer/metrics/protobuf';

/**
* OTLP-gRPC metric exporter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { OTLPMetricExporterOptions } from '../../OTLPMetricExporterOptions';
import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';
import { OTLPExporterConfigBase } from '@opentelemetry/otlp-exporter-base';
import { JsonMetricsSerializer } from '@opentelemetry/otlp-transformer';
import { JsonMetricsSerializer } from '@opentelemetry/otlp-transformer/metrics/json';
import { createLegacyOtlpBrowserExportDelegate } from '@opentelemetry/otlp-exporter-base/browser-http';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { OTLPMetricExporterOptions } from '../../OTLPMetricExporterOptions';
import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';
import { OTLPExporterNodeConfigBase } from '@opentelemetry/otlp-exporter-base';
import { JsonMetricsSerializer } from '@opentelemetry/otlp-transformer';
import { JsonMetricsSerializer } from '@opentelemetry/otlp-transformer/metrics/json';
import { VERSION } from '../../version';
import {
convertLegacyHttpOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { OTLPMetricExporterOptions } from '@opentelemetry/exporter-metrics-otlp-http';
import { OTLPMetricExporterBase } from '@opentelemetry/exporter-metrics-otlp-http';
import { OTLPExporterNodeConfigBase } from '@opentelemetry/otlp-exporter-base';
import { ProtobufMetricsSerializer } from '@opentelemetry/otlp-transformer';
import { ProtobufMetricsSerializer } from '@opentelemetry/otlp-transformer/metrics/protobuf';
import { VERSION } from './version';
import {
convertLegacyHttpOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import { createLoggingPartialSuccessResponseHandler } from '../../src/logging-response-handler';
import * as sinon from 'sinon';
import { IExportTraceServiceResponse } from '@opentelemetry/otlp-transformer';
import { IExportTraceServiceResponse } from '@opentelemetry/otlp-transformer/trace';
import { registerMockDiagLogger } from './test-utils';

describe('loggingResponseHandler', function () {
Expand Down
96 changes: 96 additions & 0 deletions experimental/packages/otlp-transformer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,102 @@
"esnext": "build/esnext/index.js",
"types": "build/src/index.d.ts",
"main": "build/src/index.js",
"exports": {
".": {
"module": "./build/esm/index.js",
"esnext": "./build/esnext/index.js",
"types": "./build/src/index.d.ts",
"default": "./build/src/index.js"
},
"./metrics": {
"module": "./build/esm/metrics/index.js",
"esnext": "./build/esnext/metrics/index.js",
"types": "./build/src/metrics/index.d.ts",
"default": "./build/src/metrics/index.js"
},
"./metrics/protobuf": {
"module": "./build/esm/metrics/protobuf/index.js",
"esnext": "./build/esnext/metrics/protobuf/index.js",
"types": "./build/src/metrics/protobuf/index.d.ts",
"default": "./build/src/metrics/protobuf/index.js"
},
"./metrics/json": {
"module": "./build/esm/metrics/json/index.js",
"esnext": "./build/esnext/metrics/json/index.js",
"types": "./build/src/metrics/json/index.d.ts",
"default": "./build/src/metrics/json/index.js"
},
"./trace": {
"module": "./build/esm/trace/index.js",
"esnext": "./build/esnext/trace/index.js",
"types": "./build/src/trace/index.d.ts",
"default": "./build/src/trace/index.js"
},
"./trace/protobuf": {
"module": "./build/esm/trace/protobuf/index.js",
"esnext": "./build/esnext/trace/protobuf/index.js",
"types": "./build/src/trace/protobuf/index.d.ts",
"default": "./build/src/trace/protobuf/index.js"
},
"./trace/json": {
"module": "./build/esm/trace/json/index.js",
"esnext": "./build/esnext/trace/json/index.js",
"types": "./build/src/trace/json/index.d.ts",
"default": "./build/src/trace/json/index.js"
},
"./experimental/logs": {
"module": "./build/esm/logs/index.js",
"esnext": "./build/esnext/logs/index.js",
"types": "./build/src/logs/index.d.ts",
"default": "./build/src/logs/index.js"
},
"./experimental/logs/protobuf": {
"module": "./build/esm/logs/protobuf/index.js",
"esnext": "./build/esnext/logs/protobuf/index.js",
"types": "./build/src/logs/protobuf/index.d.ts",
"default": "./build/src/logs/protobuf/index.js"
},
"./experimental/logs/json": {
"module": "./build/esm/logs/json/index.js",
"esnext": "./build/esnext/logs/json/index.js",
"types": "./build/src/logs/json/index.d.ts",
"default": "./build/src/logs/json/index.js"
}
},
"typesVersions": {
"*": {
"*": [
"./build/src/index.d.ts"
],
"metrics": [
"./build/src/metrics/index.d.ts"
],
"metrics/protobuf": [
"./build/src/metrics/protobuf/index.d.ts"
],
"metrics/json": [
"./build/src/metrics/json/index.d.ts"
],
"trace": [
"./build/src/trace/index.d.ts"
],
"trace/protobuf": [
"./build/src/trace/protobuf/index.d.ts"
],
"trace/json": [
"./build/src/trace/json/index.d.ts"
],
"experimental/logs": [
"./build/src/logs/index.d.ts"
],
"experimental/logs/protobuf": [
"./build/src/logs/protobuf/index.d.ts"
],
"experimental/logs/json": [
"./build/src/logs/json/index.d.ts"
]
}
},
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"prepublishOnly": "npm run compile",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
* limitations under the License.
*/

/** Properties of a Resource. */
export interface IResource {
/** Resource attributes */
attributes: IKeyValue[];

/** Resource droppedAttributesCount */
droppedAttributesCount: number;
}

/** Properties of an InstrumentationScope. */
export interface IInstrumentationScope {
/** InstrumentationScope name */
Expand Down
15 changes: 14 additions & 1 deletion experimental/packages/otlp-transformer/src/common/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { IAnyValue, IInstrumentationScope, IKeyValue } from './types';
import type {
IAnyValue,
IInstrumentationScope,
IKeyValue,
IResource,
} from './internal-types';
import { Attributes } from '@opentelemetry/api';
import { InstrumentationScope } from '@opentelemetry/core';
import { IResource as ISdkResource } from '@opentelemetry/resources';

export function createResource(resource: ISdkResource): IResource {
return {
attributes: toAttributes(resource.attributes),
droppedAttributesCount: 0,
};
}

export function createInstrumentationScope(
scope: InstrumentationScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import type { OtlpEncodingOptions, Fixed64, LongBits } from './types';
import type { OtlpEncodingOptions, Fixed64, LongBits } from './internal-types';
import { HrTime } from '@opentelemetry/api';
import { hexToBinary, hrTimeToNanoseconds } from '@opentelemetry/core';

Expand Down
27 changes: 1 addition & 26 deletions experimental/packages/otlp-transformer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,4 @@
* limitations under the License.
*/

export {
IExportMetricsPartialSuccess,
IExportMetricsServiceResponse,
} from './metrics/types';
export {
IExportTracePartialSuccess,
IExportTraceServiceResponse,
} from './trace/types';
export {
IExportLogsServiceResponse,
IExportLogsPartialSuccess,
} from './logs/types';

export {
ProtobufLogsSerializer,
ProtobufMetricsSerializer,
ProtobufTraceSerializer,
} from './protobuf/serializers';

export {
JsonTraceSerializer,
JsonLogsSerializer,
JsonMetricsSerializer,
} from './json/serializers';

export { ISerializer } from './common/i-serializer';
export { ISerializer } from './i-serializer';
Loading

0 comments on commit ebf6beb

Please sign in to comment.