Skip to content

Commit

Permalink
Merge branch 'main' into ts-4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan authored Jun 1, 2021
2 parents bd1a8c1 + 56c032e commit 0447995
Show file tree
Hide file tree
Showing 50 changed files with 503 additions and 664 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ To request automatic tracing support for a module not on this list, please [file

- `JaegerHttpTracePropagator` renamed to `JaegerPropagator`

- `serviceName` configuration removed from Collector exporters. Use `service.name` Resource attribute instead.

### 0.18.x to 0.19.0

- API is now a peer dependency. This means that users will need to include `@opentelemetry/api` as a dependency of their project in order to use the SDK. NPM version 7+ (Node 15+) should do this automatically.
Expand Down
2 changes: 2 additions & 0 deletions packages/opentelemetry-core/src/utils/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export type ENVIRONMENT = {
OTEL_EXPORTER_ZIPKIN_ENDPOINT?: string;
OTEL_LOG_LEVEL?: DiagLogLevel;
OTEL_RESOURCE_ATTRIBUTES?: string;
OTEL_SERVICE_NAME?: string;
OTEL_TRACES_EXPORTER?: string;
OTEL_TRACES_SAMPLER_ARG?: string;
OTEL_TRACES_SAMPLER?: string;
Expand Down Expand Up @@ -115,6 +116,7 @@ export const DEFAULT_ENVIRONMENT: Required<ENVIRONMENT> = {
OTEL_NO_PATCH_MODULES: [],
OTEL_PROPAGATORS: ['tracecontext', 'baggage'],
OTEL_RESOURCE_ATTRIBUTES: '',
OTEL_SERVICE_NAME: '',
OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT: 128,
OTEL_SPAN_EVENT_COUNT_LIMIT: 128,
OTEL_SPAN_LINK_COUNT_LIMIT: 128,
Expand Down
10 changes: 6 additions & 4 deletions packages/opentelemetry-exporter-collector-grpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ This module provides exporter for web and node to be used with [opentelemetry-co
npm install --save @opentelemetry/exporter-collector-grpc
```

## Service Name

The OpenTelemetry Collector Exporter does not have a service name configuration.
In order to set the service name, use the `service.name` resource attribute as prescribed in the [OpenTelemetry Resource Semantic Conventions][semconv-resource-service-name].

## Traces in Node - GRPC

The CollectorTraceExporter in Node expects the URL to only be the hostname. It will not work with `/v1/traces`.
Expand All @@ -22,7 +27,6 @@ const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/tra
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-grpc');

const collectorOptions = {
serviceName: 'basic-service',
// url is optional and can be omitted - default is localhost:4317
url: '<collector-hostname>:<port>',
};
Expand All @@ -47,7 +51,6 @@ const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/tra
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-grpc');

const collectorOptions = {
serviceName: 'basic-service',
// url is optional and can be omitted - default is localhost:4317
url: '<collector-hostname>:<port>',
credentials: grpc.credentials.createSsl(),
Expand Down Expand Up @@ -88,7 +91,6 @@ const metadata = new grpc.Metadata();
metadata.set('k', 'v');

const collectorOptions = {
serviceName: 'basic-service',
// url is optional and can be omitted - default is localhost:4317
url: '<collector-hostname>:<port>',
metadata, // // an optional grpc.Metadata object to be sent with each request
Expand All @@ -114,7 +116,6 @@ The CollectorTraceExporter in Node expects the URL to only be the hostname. It w
const { MeterProvider } = require('@opentelemetry/metrics');
const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector-grpc');
const collectorOptions = {
serviceName: 'basic-service',
// url is optional and can be omitted - default is localhost:4317
url: '<collector-hostname>:<port>',
};
Expand Down Expand Up @@ -161,3 +162,4 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
[npm-url]: https://www.npmjs.com/package/@opentelemetry/exporter-collector-grpc
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fexporter-collector-grpc.svg
[opentelemetry-collector-url]: https://github.com/open-telemetry/opentelemetry-collector
[semconv-resource-service-name]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#service
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { CollectorExporterNodeBase } from './CollectorExporterNodeBase';
import { getEnv } from '@opentelemetry/core';
import { validateAndNormalizeUrl } from './util';

const DEFAULT_SERVICE_NAME = 'collector-metric-exporter';
const DEFAULT_COLLECTOR_URL = 'localhost:4317';

/**
Expand Down Expand Up @@ -59,10 +58,6 @@ export class CollectorMetricExporter
: DEFAULT_COLLECTOR_URL;
}

getDefaultServiceName(config: CollectorExporterConfigNode): string {
return config.serviceName || DEFAULT_SERVICE_NAME;
}

getServiceClientType() {
return ServiceClientType.METRICS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { CollectorExporterConfigNode, ServiceClientType } from './types';
import { getEnv } from '@opentelemetry/core';
import { validateAndNormalizeUrl } from './util';

const DEFAULT_SERVICE_NAME = 'collector-trace-exporter';
const DEFAULT_COLLECTOR_URL = 'localhost:4317';

/**
Expand Down Expand Up @@ -52,10 +51,6 @@ export class CollectorTraceExporter
: DEFAULT_COLLECTOR_URL;
}

getDefaultServiceName(config: CollectorExporterConfigNode): string {
return config.serviceName || DEFAULT_SERVICE_NAME;
}

getServiceClientType() {
return ServiceClientType.SPANS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ const testCollectorMetricExporter = (params: TestParams) =>
collectorExporter = new CollectorMetricExporter({
url: 'grpcs://' + address,
credentials,
serviceName: 'basic-service',
metadata: params.metadata,
});
// Overwrites the start time to make tests consistent
Expand Down Expand Up @@ -169,7 +168,6 @@ const testCollectorMetricExporter = (params: TestParams) =>
// Need to stub/spy on the underlying logger as the 'diag' instance is global
const spyLoggerWarn = sinon.stub(diag, 'warn');
collectorExporter = new CollectorMetricExporter({
serviceName: 'basic-service',
url: `http://${address}`,
headers: {
foo: 'bar',
Expand All @@ -181,7 +179,6 @@ const testCollectorMetricExporter = (params: TestParams) =>
it('should warn about path in url', () => {
const spyLoggerWarn = sinon.stub(diag, 'warn');
collectorExporter = new CollectorMetricExporter({
serviceName: 'basic-service',
url: `http://${address}/v1/metrics`
});
const args = spyLoggerWarn.args[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ const testCollectorExporter = (params: TestParams) =>
)
: undefined;
collectorExporter = new CollectorTraceExporter({
serviceName: 'basic-service',
url: 'grpcs://' + address,
credentials,
metadata: params.metadata,
Expand All @@ -146,7 +145,6 @@ const testCollectorExporter = (params: TestParams) =>
// Need to stub/spy on the underlying logger as the 'diag' instance is global
const spyLoggerWarn = sinon.stub(diag, 'warn');
collectorExporter = new CollectorTraceExporter({
serviceName: 'basic-service',
url: `http://${address}`,
headers: {
foo: 'bar',
Expand All @@ -158,7 +156,6 @@ const testCollectorExporter = (params: TestParams) =>
it('should warn about path in url', () => {
const spyLoggerWarn = sinon.stub(diag, 'warn');
collectorExporter = new CollectorTraceExporter({
serviceName: 'basic-service',
url: `http://${address}/v1/trace`,
});
const args = spyLoggerWarn.args[0];
Expand Down
36 changes: 29 additions & 7 deletions packages/opentelemetry-exporter-collector-grpc/test/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { Resource } from '@opentelemetry/resources';
import { ReadableSpan } from '@opentelemetry/tracing';
import * as assert from 'assert';
import * as grpc from '@grpc/grpc-js';
import { VERSION } from '@opentelemetry/core';

const meterProvider = new metrics.MeterProvider({
interval: 30000,
Expand Down Expand Up @@ -157,11 +158,11 @@ export const mockedReadableSpan: ReadableSpan = {
},
],
duration: [0, 8885000],
resource: new Resource({
resource: Resource.default().merge(new Resource({
service: 'ui',
version: 1,
cost: 112.12,
}),
})),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
};

Expand Down Expand Up @@ -409,11 +410,32 @@ export function ensureResourceIsCorrect(
assert.deepStrictEqual(resource, {
attributes: [
{
key: 'service.name',
value: {
stringValue: 'basic-service',
value: 'stringValue',
},
"key": "service.name",
"value": {
"stringValue": `unknown_service:${process.argv0}`,
"value": "stringValue"
}
},
{
"key": "telemetry.sdk.language",
"value": {
"stringValue": "nodejs",
"value": "stringValue"
}
},
{
"key": "telemetry.sdk.name",
"value": {
"stringValue": "opentelemetry",
"value": "stringValue"
}
},
{
"key": "telemetry.sdk.version",
"value": {
"stringValue": VERSION,
"value": "stringValue"
}
},
{
key: 'service',
Expand Down
8 changes: 6 additions & 2 deletions packages/opentelemetry-exporter-collector-proto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ This module provides exporter for node to be used with [opentelemetry-collector]
npm install --save @opentelemetry/exporter-collector-proto
```

## Service Name

The OpenTelemetry Collector Exporter does not have a service name configuration.
In order to set the service name, use the `service.name` resource attribute as prescribed in the [OpenTelemetry Resource Semantic Conventions][semconv-resource-service-name].

## Traces in Node - PROTO over http

```js
const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-proto');

const collectorOptions = {
serviceName: 'basic-service',
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:55681/v1/traces
headers: {
foo: 'bar'
Expand All @@ -41,7 +45,6 @@ provider.register();
const { MeterProvider } = require('@opentelemetry/metrics');
const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector-proto');
const collectorOptions = {
serviceName: 'basic-service',
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:55681/v1/metrics
};
const exporter = new CollectorMetricExporter(collectorOptions);
Expand Down Expand Up @@ -84,3 +87,4 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
[npm-url]: https://www.npmjs.com/package/@opentelemetry/exporter-collector-proto
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fexporter-collector-proto.svg
[opentelemetry-collector-url]: https://github.com/open-telemetry/opentelemetry-collector
[semconv-resource-service-name]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#service
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { ServiceClientType } from './types';
import { CollectorExporterNodeBase } from './CollectorExporterNodeBase';
import { getEnv, baggageUtils } from '@opentelemetry/core';

const DEFAULT_SERVICE_NAME = 'collector-metric-exporter';
const DEFAULT_COLLECTOR_URL = 'http://localhost:4317/v1/metrics';

/**
Expand Down Expand Up @@ -69,10 +68,6 @@ export class CollectorMetricExporter
: DEFAULT_COLLECTOR_URL;
}

getDefaultServiceName(config: CollectorExporterNodeConfigBase): string {
return config.serviceName || DEFAULT_SERVICE_NAME;
}

getServiceClientType() {
return ServiceClientType.METRICS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
import { ServiceClientType } from './types';
import { getEnv, baggageUtils } from '@opentelemetry/core';

const DEFAULT_SERVICE_NAME = 'collector-trace-exporter';
const DEFAULT_COLLECTOR_URL = 'http://localhost:4317/v1/traces';

/**
Expand Down Expand Up @@ -62,10 +61,6 @@ export class CollectorTraceExporter
: DEFAULT_COLLECTOR_URL;
}

getDefaultServiceName(config: CollectorExporterNodeConfigBase): string {
return config.serviceName || DEFAULT_SERVICE_NAME;
}

getServiceClientType() {
return ServiceClientType.SPANS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ describe('CollectorMetricExporter - node with proto over http', () => {
foo: 'bar',
},
hostname: 'foo',
serviceName: 'bar',
attributes: {},
url: 'http://foo.bar.com',
keepAlive: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ describe('CollectorTraceExporter - node with proto over http', () => {
foo: 'bar',
},
hostname: 'foo',
serviceName: 'bar',
attributes: {},
url: 'http://foo.bar.com',
keepAlive: true,
Expand Down
8 changes: 6 additions & 2 deletions packages/opentelemetry-exporter-collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ This module provides exporter for web and node to be used with [opentelemetry-co
npm install --save @opentelemetry/exporter-collector
```

## Service Name

The OpenTelemetry Collector Exporter does not have a service name configuration.
In order to set the service name, use the `service.name` resource attribute as prescribed in the [OpenTelemetry Resource Semantic Conventions][semconv-resource-service-name].

## Traces in Web

The CollectorTraceExporter in Web expects the endpoint to end in `/v1/traces`.
Expand Down Expand Up @@ -78,7 +83,6 @@ const { BasicTracerProvider, BatchSpanProcessor } = require('@opentelemetry/trac
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector');

const collectorOptions = {
serviceName: 'basic-service',
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:55681/v1/trace
headers: {
foo: 'bar'
Expand All @@ -105,7 +109,6 @@ provider.register();
const { MeterProvider } = require('@opentelemetry/metrics');
const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector');
const collectorOptions = {
serviceName: 'basic-service',
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:55681/v1/metrics
concurrencyLimit: 1, // an optional limit on pending requests
};
Expand Down Expand Up @@ -159,3 +162,4 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
[npm-url-proto]: https://www.npmjs.com/package/@opentelemetry/exporter-collector-proto
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fexporter-collector.svg
[opentelemetry-collector-url]: https://github.com/open-telemetry/opentelemetry-collector
[semconv-resource-service-name]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#service
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export abstract class CollectorExporterBase<
ExportItem,
ServiceRequest
> {
public readonly serviceName: string;
public readonly url: string;
public readonly hostname: string | undefined;
public readonly attributes?: SpanAttributes;
Expand All @@ -43,7 +42,6 @@ export abstract class CollectorExporterBase<
* @param config
*/
constructor(config: T = {} as T) {
this.serviceName = this.getDefaultServiceName(config);
this.url = this.getDefaultUrl(config);
if (typeof config.hostname === 'string') {
this.hostname = config.hostname;
Expand Down Expand Up @@ -140,6 +138,5 @@ export abstract class CollectorExporterBase<
onError: (error: CollectorExporterError) => void
): void;
abstract getDefaultUrl(config: T): string;
abstract getDefaultServiceName(config: T): string;
abstract convert(objects: ExportItem[]): ServiceRequest;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { toCollectorExportMetricServiceRequest } from '../../transformMetrics';
import { getEnv, baggageUtils } from '@opentelemetry/core';

const DEFAULT_COLLECTOR_URL = 'http://localhost:55681/v1/metrics';
const DEFAULT_SERVICE_NAME = 'collector-metric-exporter';

/**
* Collector Metric Exporter for Web
Expand Down Expand Up @@ -65,8 +64,4 @@ export class CollectorMetricExporter
? getEnv().OTEL_EXPORTER_OTLP_ENDPOINT
: DEFAULT_COLLECTOR_URL;
}

getDefaultServiceName(config: CollectorExporterConfigBase): string {
return config.serviceName || DEFAULT_SERVICE_NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { toCollectorExportTraceServiceRequest } from '../../transform';
import * as collectorTypes from '../../types';
import { getEnv, baggageUtils } from '@opentelemetry/core';

const DEFAULT_SERVICE_NAME = 'collector-trace-exporter';
const DEFAULT_COLLECTOR_URL = 'http://localhost:55681/v1/traces';

/**
Expand Down Expand Up @@ -57,8 +56,4 @@ export class CollectorTraceExporter
? getEnv().OTEL_EXPORTER_OTLP_ENDPOINT
: DEFAULT_COLLECTOR_URL;
}

getDefaultServiceName(config: CollectorExporterConfigBase): string {
return config.serviceName ?? DEFAULT_SERVICE_NAME;
}
}
Loading

0 comments on commit 0447995

Please sign in to comment.