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

refactor!: replace SpanAttributes, MetricsAttributes and ResourceAttributes with Attributes #4928

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se

### :boom: Breaking Change

* refactor!: replace `SpanAttributes`, `MetricsAttributes` and `ResourceAttributes` with `Attributes` [#4928](https://github.com/open-telemetry/opentelemetry-js/pull/4928)
* fix(otlp-exporter-base)!: decrease default concurrency limit to 30 [#4211](https://github.com/open-telemetry/opentelemetry-js/pull/4211) @pichlermarc
* fixes a memory leak on prolonged collector unavailability
* this change is marked as breaking as it changes defaults
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-tracer-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
},
"dependencies": {
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/exporter-jaeger": "0.25.0",
"@opentelemetry/resources": "0.25.0",
"@opentelemetry/semantic-conventions": "^1.22.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/grpc-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@grpc/grpc-js": "^1.3.7",
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/exporter-jaeger": "^1.0.1",
"@opentelemetry/exporter-zipkin": "^1.0.1",
"@opentelemetry/instrumentation": "^0.27.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/https/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
},
"dependencies": {
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/exporter-jaeger": "1.25.1",
"@opentelemetry/exporter-zipkin": "1.25.1",
"@opentelemetry/instrumentation": "0.52.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/opentracing-shim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
},
"dependencies": {
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/exporter-jaeger": "0.25.0",
"@opentelemetry/exporter-zipkin": "0.25.0",
"@opentelemetry/instrumentation": "0.25.0",
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/api-events/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"access": "public"
},
"dependencies": {
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/api-logs": "0.52.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/api-logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"access": "public"
},
"dependencies": {
"@opentelemetry/api": "^1.0.0"
"@opentelemetry/api": "^1.3.0"
},
"devDependencies": {
"@types/mocha": "10.0.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"typescript": "4.4.4"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.0"
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@grpc/grpc-js": "^1.7.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"webpack-merge": "5.10.0"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.0"
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@opentelemetry/api-logs": "0.52.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"webpack-merge": "5.10.0"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.0"
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@opentelemetry/api-logs": "0.52.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"typescript": "4.4.4"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.0"
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@grpc/grpc-js": "^1.7.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"webpack-merge": "5.10.0"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.0"
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@opentelemetry/core": "1.25.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"webpack-merge": "5.10.0"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.0"
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@opentelemetry/core": "1.25.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"webpack-merge": "5.10.0"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.0"
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@opentelemetry/resources": "1.25.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
* limitations under the License.
*/

import { diag } from '@opentelemetry/api';
import { Attributes, diag } from '@opentelemetry/api';
import {
Detector,
IResource,
Resource,
ResourceDetectionConfig,
} from '@opentelemetry/resources';
import { ResourceAttributes } from '@opentelemetry/resources';
import { BROWSER_ATTRIBUTES, UserAgentData } from './types';

/**
Expand All @@ -33,7 +32,7 @@ class BrowserDetector implements Detector {
if (!isBrowser) {
return Resource.empty();
}
const browserResource: ResourceAttributes = getBrowserAttributes();
const browserResource: Attributes = getBrowserAttributes();
return this._getResourceAttributes(browserResource, config);
}
/**
Expand All @@ -44,7 +43,7 @@ class BrowserDetector implements Detector {
* @returns The sanitized resource attributes.
*/
private _getResourceAttributes(
browserResource: ResourceAttributes,
browserResource: Attributes,
_config?: ResourceDetectionConfig
) {
if (
Expand All @@ -62,8 +61,8 @@ class BrowserDetector implements Detector {
}

// Add Browser related attributes to resources
function getBrowserAttributes(): ResourceAttributes {
const browserAttribs: ResourceAttributes = {};
function getBrowserAttributes(): Attributes {
const browserAttribs: Attributes = {};
const userAgentData: UserAgentData | undefined = (navigator as any)
.userAgentData;
if (userAgentData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
* limitations under the License.
*/

import {
diag,
MetricAttributes,
MetricAttributeValue,
} from '@opentelemetry/api';
import { diag, Attributes, AttributeValue } from '@opentelemetry/api';
import {
ResourceMetrics,
InstrumentType,
Expand Down Expand Up @@ -48,7 +44,7 @@ function escapeString(str: string) {
*
* `undefined` is converted to an empty string.
*/
function escapeAttributeValue(str: MetricAttributeValue = '') {
function escapeAttributeValue(str: AttributeValue = '') {
if (typeof str !== 'string') {
str = JSON.stringify(str);
}
Expand Down Expand Up @@ -136,10 +132,10 @@ function toPrometheusType(metricData: MetricData): PrometheusDataTypeLiteral {

function stringify(
metricName: string,
attributes: MetricAttributes,
attributes: Attributes,
value: number,
timestamp?: number,
additionalAttributes?: MetricAttributes
additionalAttributes?: Attributes
) {
let hasAttribute = false;
let attributesStr = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import * as assert from 'assert';
import { MetricAttributes, UpDownCounter } from '@opentelemetry/api';
import { Attributes, UpDownCounter } from '@opentelemetry/api';
import {
Aggregation,
AggregationTemporality,
Expand Down Expand Up @@ -610,7 +610,7 @@ describe('PrometheusSerializer', () => {
NaN: NaN,
null: null,
undefined: undefined,
} as unknown as MetricAttributes);
} as unknown as Attributes);
});

assert.strictEqual(
Expand Down Expand Up @@ -649,7 +649,7 @@ describe('PrometheusSerializer', () => {
backslashN: '\u005c\u006e', // \n => \\n (\u005c\u005c\u006e)
backslashDoubleQuote: '\u005c\u0022', // \" => \\\" (\u005c\u005c\u005c\u0022)
backslashLineFeed: '\u005c\u000a', // \↵ => \\\n (\u005c\u005c\u005c\u006e)
} as unknown as MetricAttributes);
} as unknown as Attributes);
});

assert.strictEqual(
Expand All @@ -674,7 +674,7 @@ describe('PrometheusSerializer', () => {
// error while linting: text format parsing error in line 282: expected '=' after label name, found '-'
counter.add(1, {
'account-id': '123456',
} as unknown as MetricAttributes);
} as unknown as Attributes);
});

assert.strictEqual(result, 'test_total{account_id="123456"} 1\n');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"webpack-merge": "5.10.0"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.0"
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@opentelemetry/core": "1.25.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
SpanStatusCode,
trace,
Histogram,
MetricAttributes,
Attributes,
ValueType,
} from '@opentelemetry/api';
import {
Expand Down Expand Up @@ -296,7 +296,7 @@ export class HttpInstrumentation extends InstrumentationBase<HttpInstrumentation
request: http.ClientRequest,
span: Span,
startTime: HrTime,
metricAttributes: MetricAttributes
metricAttributes: Attributes
): http.ClientRequest {
if (this.getConfig().requestHook) {
this._callRequestHook(span, request);
Expand Down Expand Up @@ -631,7 +631,7 @@ export class HttpInstrumentation extends InstrumentationBase<HttpInstrumentation
});

const startTime = hrTime();
const metricAttributes: MetricAttributes =
const metricAttributes: Attributes =
utils.getOutgoingRequestMetricAttributes(attributes);

const spanOptions: SpanOptions = {
Expand Down Expand Up @@ -696,7 +696,7 @@ export class HttpInstrumentation extends InstrumentationBase<HttpInstrumentation
request: http.IncomingMessage,
response: http.ServerResponse,
span: Span,
metricAttributes: MetricAttributes,
metricAttributes: Attributes,
startTime: HrTime
) {
const attributes = utils.getIncomingRequestAttributesOnResponse(
Expand Down Expand Up @@ -739,7 +739,7 @@ export class HttpInstrumentation extends InstrumentationBase<HttpInstrumentation

private _onServerResponseError(
span: Span,
metricAttributes: MetricAttributes,
metricAttributes: Attributes,
startTime: HrTime,
error: Err
) {
Expand Down Expand Up @@ -779,7 +779,7 @@ export class HttpInstrumentation extends InstrumentationBase<HttpInstrumentation
span: Span,
spanKind: SpanKind,
startTime: HrTime,
metricAttributes: MetricAttributes
metricAttributes: Attributes
) {
if (!this._spanNotEnded.has(span)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Span, SpanAttributes } from '@opentelemetry/api';
import { Span, Attributes } from '@opentelemetry/api';
import type * as http from 'http';
import type * as https from 'https';
import {
Expand Down Expand Up @@ -73,11 +73,11 @@ export interface HttpResponseCustomAttributeFunction {
}

export interface StartIncomingSpanCustomAttributeFunction {
(request: IncomingMessage): SpanAttributes;
(request: IncomingMessage): Attributes;
}

export interface StartOutgoingSpanCustomAttributeFunction {
(request: RequestOptions): SpanAttributes;
(request: RequestOptions): Attributes;
}

/**
Expand Down
Loading