Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Split metric and trace exporters into new experimental packages #2485

Merged
merged 26 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
32d7962
chore: updating submodule for opentelemetry-proto
Sep 21, 2021
f9972c8
chore: initialized exporter-metrics-otlp-grpc package
Sep 21, 2021
9685772
feat\!: populated exporter-metrics-otlp-grpc package
Sep 21, 2021
007970c
chore: bootstrapped exporter-metrics-otlp-http package
Sep 21, 2021
9618274
feat\!: migrated metric exporter logic to exporter-metrics-otlp-http
Sep 21, 2021
d2ecae0
chore: updating submodule for opentelemetry-proto
Sep 21, 2021
07b43bf
chore: bootstrapped exporter-metrics-otlp-proto package
Sep 21, 2021
5ac7d7b
feat!: migrated proto logic to exporter-metrics-otlp-proto package
Sep 21, 2021
308cfe3
fix: fixed some issues in grpc and proto
Sep 22, 2021
16e7a95
removed debug logging
Sep 22, 2021
c50cada
added api to devdeps
Sep 22, 2021
e5ed763
merge branch 'main' into split-exporters
Sep 29, 2021
0751815
fixed imports
Sep 29, 2021
b886cb9
merge 'main' into split-exporters
Oct 5, 2021
211fa12
updated versions to latest
Oct 5, 2021
9140258
fixed merge conflicts
Oct 26, 2021
8b3571f
applied changes from #2496 to metricHelpers
Oct 26, 2021
752463e
renamed exporter-otlp-http -> exporter-trace-otlp-http
Oct 26, 2021
c4aa74a
renamed exporter-otlp-grpc -> exporter-trace-otlp-grpc
Oct 26, 2021
3e7daf4
renamed exporter-otlp-proto -> exporter-trace-otlp-proto
Oct 26, 2021
44de3a7
Merge branch 'main' into split-exporters
dyladan Oct 26, 2021
8eccf90
Merge branch 'main' into split-exporters
vmarchaud Oct 27, 2021
2992e5c
fix conflicts and bump api version
Oct 28, 2021
81891ec
Merge branch 'split-exporters' of https://github.com/willarmiros/open…
Oct 28, 2021
353d038
Merge branch 'main' into split-exporters
dyladan Nov 1, 2021
e068039
Merge branch 'main' into split-exporters
rauno56 Nov 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat\!: migrated metric exporter logic to exporter-metrics-otlp-http
  • Loading branch information
William Armiros committed Sep 21, 2021
commit 961827414d84fda2d9932f187d835072b22e66ca
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
},
"devDependencies": {
"@babel/core": "7.15.0",
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/api-metrics": "0.25.0",
"@types/mocha": "8.2.3",
"@types/node": "14.17.11",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
},
"devDependencies": {
"@babel/core": "7.15.0",
"@opentelemetry/api": "^1.0.2",
"@types/mocha": "8.2.3",
"@types/node": "14.17.11",
"@types/sinon": "10.0.2",
Expand Down Expand Up @@ -89,7 +88,6 @@
"@opentelemetry/api-metrics": "0.25.0",
"@opentelemetry/core": "0.25.0",
"@opentelemetry/resources": "0.25.0",
"@opentelemetry/sdk-metrics-base": "0.25.0",
"@opentelemetry/sdk-trace-base": "0.25.0"
"@opentelemetry/sdk-metrics-base": "0.25.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export * from './platform';
export { toOTLPExportMetricServiceRequest } from './transformMetrics';
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
*/

import { MetricRecord, MetricExporter } from '@opentelemetry/sdk-metrics-base';
import { OTLPExporterConfigBase } from '../../types';
import * as otlpTypes from '../../types';
import { OTLPExporterBrowserBase } from './OTLPExporterBrowserBase';
import { otlpTypes, appendResourcePathToUrlIfNotPresent } from '../../../../../../packages/opentelemetry-exporter-otlp-http';
import { OTLPExporterBrowserBase } from '../../../../../../packages/opentelemetry-exporter-otlp-http/build/esm'
import { toOTLPExportMetricServiceRequest } from '../../transformMetrics';
import { getEnv, baggageUtils } from '@opentelemetry/core';
import { appendResourcePathToUrlIfNotPresent } from '../../util';

const DEFAULT_COLLECTOR_RESOURCE_PATH = '/v1/metrics';
const DEFAULT_COLLECTOR_URL=`http://localhost:55681${DEFAULT_COLLECTOR_RESOURCE_PATH}`;
Expand All @@ -37,7 +35,7 @@ export class OTLPMetricExporter
// Converts time to nanoseconds
private readonly _startTime = new Date().getTime() * 1000000;

constructor(config: OTLPExporterConfigBase = {}) {
constructor(config: otlpTypes.OTLPExporterConfigBase = {}) {
super(config);
this._headers = Object.assign(
this._headers,
Expand All @@ -57,7 +55,7 @@ export class OTLPMetricExporter
);
}

getDefaultUrl(config: OTLPExporterConfigBase): string {
getDefaultUrl(config: otlpTypes.OTLPExporterConfigBase): string {
return typeof config.url === 'string'
? config.url
: getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export * from './OTLPMetricExporter';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export * from './node';
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
*/

import { MetricRecord, MetricExporter } from '@opentelemetry/sdk-metrics-base';
import * as otlpTypes from '../../types';
import { OTLPExporterNodeConfigBase } from './types';
import { OTLPExporterNodeBase } from './OTLPExporterNodeBase';
import {
OTLPExporterNodeBase,
OTLPExporterNodeConfigBase,
otlpTypes,
appendResourcePathToUrlIfNotPresent
} from '../../../../../../packages/opentelemetry-exporter-otlp-http';
import { toOTLPExportMetricServiceRequest } from '../../transformMetrics';
import { getEnv, baggageUtils } from '@opentelemetry/core';
import { appendResourcePathToUrlIfNotPresent } from '../../util';

const DEFAULT_COLLECTOR_RESOURCE_PATH = '/v1/metrics';
const DEFAULT_COLLECTOR_URL=`http://localhost:55681${DEFAULT_COLLECTOR_RESOURCE_PATH}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export * from './OTLPMetricExporter';
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ import {
MetricRecord,
} from '@opentelemetry/sdk-metrics-base';
import { Resource } from '@opentelemetry/resources';
import { OTLPExporterBase } from './OTLPExporterBase';
import { toCollectorResource } from './transform';
import { OTLPExporterConfigBase, opentelemetryProto } from './types';
import { OTLPExporterBase, otlpTypes, toCollectorResource } from '../../../../packages/opentelemetry-exporter-otlp-http';

/**
* Converts labels
* @param labels
*/
export function toCollectorLabels(
labels: Labels
): opentelemetryProto.common.v1.StringKeyValue[] {
): otlpTypes.opentelemetryProto.common.v1.StringKeyValue[] {
return Object.entries(labels).map(([key, value]) => {
return { key, value: String(value) };
});
Expand All @@ -46,9 +44,9 @@ export function toCollectorLabels(
*/
export function toAggregationTemporality(
metric: MetricRecord
): opentelemetryProto.metrics.v1.AggregationTemporality {
): otlpTypes.opentelemetryProto.metrics.v1.AggregationTemporality {
if (metric.descriptor.metricKind === MetricKind.VALUE_OBSERVER) {
return opentelemetryProto.metrics.v1.AggregationTemporality
return otlpTypes.opentelemetryProto.metrics.v1.AggregationTemporality
.AGGREGATION_TEMPORALITY_UNSPECIFIED;
}

Expand All @@ -63,7 +61,7 @@ export function toAggregationTemporality(
export function toDataPoint(
metric: MetricRecord,
startTime: number
): opentelemetryProto.metrics.v1.DataPoint {
): otlpTypes.opentelemetryProto.metrics.v1.DataPoint {
return {
labels: toCollectorLabels(metric.labels),
value: metric.aggregator.toPoint().value as number,
Expand All @@ -82,7 +80,7 @@ export function toDataPoint(
export function toHistogramPoint(
metric: MetricRecord,
startTime: number
): opentelemetryProto.metrics.v1.HistogramDataPoint {
): otlpTypes.opentelemetryProto.metrics.v1.HistogramDataPoint {
const { value, timestamp } = metric.aggregator.toPoint() as {
value: Histogram;
timestamp: HrTime;
Expand All @@ -106,8 +104,8 @@ export function toHistogramPoint(
export function toCollectorMetric(
metric: MetricRecord,
startTime: number
): opentelemetryProto.metrics.v1.Metric {
const metricCollector: opentelemetryProto.metrics.v1.Metric = {
): otlpTypes.opentelemetryProto.metrics.v1.Metric {
const metricCollector: otlpTypes.opentelemetryProto.metrics.v1.Metric = {
name: metric.descriptor.name,
description: metric.descriptor.description,
unit: metric.descriptor.unit,
Expand Down Expand Up @@ -161,16 +159,16 @@ export function toCollectorMetric(
* @param collectorMetricExporterBase
*/
export function toOTLPExportMetricServiceRequest<
T extends OTLPExporterConfigBase
T extends otlpTypes.OTLPExporterConfigBase
>(
metrics: MetricRecord[],
startTime: number,
collectorExporterBase: OTLPExporterBase<
T,
MetricRecord,
opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest
otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest
>
): opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest {
): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest {
const groupedMetrics: Map<
Resource,
Map<core.InstrumentationLibrary, MetricRecord[]>
Expand Down Expand Up @@ -224,7 +222,7 @@ function toCollectorInstrumentationLibraryMetrics(
instrumentationLibrary: core.InstrumentationLibrary,
metrics: MetricRecord[],
startTime: number
): opentelemetryProto.metrics.v1.InstrumentationLibraryMetrics {
): otlpTypes.opentelemetryProto.metrics.v1.InstrumentationLibraryMetrics {
return {
metrics: metrics.map(metric => toCollectorMetric(metric, startTime)),
instrumentationLibrary,
Expand All @@ -243,7 +241,7 @@ function toCollectorResourceMetrics(
>,
baseAttributes: SpanAttributes,
startTime: number
): opentelemetryProto.metrics.v1.ResourceMetrics[] {
): otlpTypes.opentelemetryProto.metrics.v1.ResourceMetrics[] {
return Array.from(groupedMetrics, ([resource, libMetrics]) => {
return {
resource: toCollectorResource(resource, baseAttributes),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ import {
import * as assert from 'assert';
import * as sinon from 'sinon';
import { OTLPMetricExporter } from '../../src/platform/browser/index';
import * as otlpTypes from '../../src/types';
import { OTLPExporterConfigBase } from '../../src/types';
import { otlpTypes } from '../../../../../packages/opentelemetry-exporter-otlp-http';
import {
ensureCounterIsCorrect,
ensureExportMetricsServiceRequestIsSet,
Expand All @@ -43,7 +42,7 @@ import {
mockCounter,
mockObserver,
mockValueRecorder,
} from '../helper';
} from '../metricsHelper';

describe('OTLPMetricExporter - web', () => {
let collectorExporter: OTLPMetricExporter;
Expand Down Expand Up @@ -321,7 +320,7 @@ describe('OTLPMetricExporter - web', () => {
foo: 'bar',
bar: 'baz',
};
let collectorExporterConfig: OTLPExporterConfigBase;
let collectorExporterConfig: otlpTypes.OTLPExporterConfigBase;

beforeEach(() => {
collectorExporterConfig = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const testsContext = require.context('../browser', true, /test$/);
testsContext.keys().forEach(testsContext);

const testsContextCommon = require.context('../common', true, /test$/);
testsContextCommon.keys().forEach(testsContextCommon);

const srcContext = require.context('.', true, /src$/);
srcContext.keys().forEach(srcContext);
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ import {
} from '@opentelemetry/sdk-metrics-base';
import * as assert from 'assert';
import * as sinon from 'sinon';
import { OTLPExporterBase } from '../../src/OTLPExporterBase';
import * as otlpTypes from '../../src/types';
import { OTLPExporterConfigBase } from '../../src/types';
import { mockCounter, mockObserver } from '../helper';
import { OTLPExporterBase, otlpTypes } from '../../../../../packages/opentelemetry-exporter-otlp-http';
import { mockCounter, mockObserver } from '../metricsHelper';

type CollectorExporterConfig = OTLPExporterConfigBase;
type CollectorExporterConfig = otlpTypes.OTLPExporterConfigBase;
class OTLPMetricExporter extends OTLPExporterBase<
CollectorExporterConfig,
MetricRecord,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import {
mockValueRecorder,
multiInstrumentationLibraryMetricsGet,
multiResourceMetricsGet,
} from '../helper';
} from '../metricsHelper';

describe('transformMetrics', () => {
describe('toCollectorMetric', async () => {
Expand Down
Loading