Skip to content

Commit 141172e

Browse files
authored
Merge branch 'main' into feat/span-dropped-counts
2 parents 60bc89f + 95bf6fc commit 141172e

File tree

10 files changed

+161
-5
lines changed

10 files changed

+161
-5
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
1919
* perf(propagator-jaeger): improve deserializeSpanContext performance [#3541](https://github.com/open-telemetry/opentelemetry-js/pull/3541) @doochik
2020
* feat: support TraceState in SamplingResult [#3530](https://github.com/open-telemetry/opentelemetry-js/pull/3530) @raphael-theriault-swi
2121
* feat(sdk-trace-base): add diagnostic logging when spans are dropped [#3610](https://github.com/open-telemetry/opentelemetry-js/pull/3610) @neoeinstein
22-
* feat(sdk-trace-base): expose dropped counts for attributes, events and links on span [#3576](https://github.com/open-telemetry/opentelemetry-js/pull/3576)
22+
* feat: add unit to view instrument selection criteria [#3647](https://github.com/open-telemetry/opentelemetry-js/pull/3647) @jlabatut
23+
* feat(sdk-trace-base): expose dropped counts for attributes, events and links on span [#3576](https://github.com/open-telemetry/opentelemetry-js/pull/3576) @mohitk05
2324

2425
### :bug: (Bug Fix)
2526

@@ -32,6 +33,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
3233

3334
### :house: (Internal)
3435

36+
* chore(exporter-jaeger): deprecate jaeger exporter [#3585](https://github.com/open-telemetry/opentelemetry-js/pull/3585) @pichlermarc
3537
* fix(sdk-metrics): fix flaky LastValueAggregator test by using fake timer [#3587](https://github.com/open-telemetry/opentelemetry-js/pull/3587) @pichlermarc
3638
* fix(test): fix failing tests by preventing source-map generation [#3642](https://github.com/open-telemetry/opentelemetry-js/pull/3642) @pichlermarc
3739

packages/opentelemetry-exporter-jaeger/README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
# OpenTelemetry Jaeger Trace Exporter for Node.js
1+
# (Deprecated) OpenTelemetry Jaeger Trace Exporter for Node.js
22

33
[![NPM Published Version][npm-img]][npm-url]
44
[![Apache License][license-image]][license-image]
55

6+
**NOTE: Support for `@opentelemetry/exporter-jaeger` will end March 2024, please use any of the following packages instead:**
7+
8+
- `@opentelemetry/exporter-trace-otlp-proto`
9+
- `@opentelemetry/exporter-trace-otlp-grpc`
10+
- `@opentelemetry/exporter-trace-otlp-http`
11+
612
OpenTelemetry Jaeger Trace Exporter allows the user to send collected traces to Jaeger.
713

814
[Jaeger](https://jaeger.readthedocs.io/en/latest/), inspired by [Dapper](https://research.google.com/pubs/pub36356.html) and [OpenZipkin](http://zipkin.io/), is a distributed tracing system released as open source by [Uber Technologies](http://uber.github.io/). It is used for monitoring and troubleshooting microservices-based distributed systems, including:

packages/opentelemetry-exporter-jaeger/src/jaeger.ts

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ import * as jaegerTypes from './types';
2929

3030
/**
3131
* Format and sends span information to Jaeger Exporter.
32+
*
33+
* @deprecated Jaeger supports the OpenTelemetry protocol natively
34+
* (see https://www.jaegertracing.io/docs/1.41/apis/#opentelemetry-protocol-stable).
35+
* This exporter will not be required by the OpenTelemetry specification starting July 2023, and
36+
* will not receive any security fixes past March 2024.
37+
*
38+
* Please migrate to any of the following packages:
39+
* - `@opentelemetry/exporter-trace-otlp-proto`
40+
* - `@opentelemetry/exporter-trace-otlp-grpc`
41+
* - `@opentelemetry/exporter-trace-otlp-http`
3242
*/
3343
export class JaegerExporter implements SpanExporter {
3444
private readonly _onShutdownFlushTimeout: number;

packages/sdk-metrics/src/view/InstrumentSelector.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,23 @@
1515
*/
1616

1717
import { InstrumentType } from '../InstrumentDescriptor';
18-
import { PatternPredicate, Predicate } from './Predicate';
18+
import { ExactPredicate, PatternPredicate, Predicate } from './Predicate';
1919

2020
export interface InstrumentSelectorCriteria {
2121
name?: string;
2222
type?: InstrumentType;
23+
unit?: string;
2324
}
2425

2526
export class InstrumentSelector {
2627
private _nameFilter: Predicate;
2728
private _type?: InstrumentType;
29+
private _unitFilter: Predicate;
2830

2931
constructor(criteria?: InstrumentSelectorCriteria) {
3032
this._nameFilter = new PatternPredicate(criteria?.name ?? '*');
3133
this._type = criteria?.type;
34+
this._unitFilter = new ExactPredicate(criteria?.unit);
3235
}
3336

3437
getType() {
@@ -38,4 +41,8 @@ export class InstrumentSelector {
3841
getNameFilter() {
3942
return this._nameFilter;
4043
}
44+
45+
getUnitFilter() {
46+
return this._unitFilter;
47+
}
4148
}

packages/sdk-metrics/src/view/RegistrationConflicts.ts

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export function getTypeConflictResolutionRecipe(
5959
const selector: InstrumentSelectorCriteria = {
6060
name: otherDescriptor.name,
6161
type: otherDescriptor.type,
62+
unit: otherDescriptor.unit,
6263
};
6364

6465
const selectorString = JSON.stringify(selector);
@@ -73,6 +74,7 @@ export function getDescriptionResolutionRecipe(
7374
const selector: InstrumentSelectorCriteria = {
7475
name: otherDescriptor.name,
7576
type: otherDescriptor.type,
77+
unit: otherDescriptor.unit,
7678
};
7779

7880
const selectorString = JSON.stringify(selector);

packages/sdk-metrics/src/view/View.ts

+13
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ export type ViewOptions = {
8383
* instrumentName: 'my.instruments.requests'
8484
*/
8585
instrumentName?: string;
86+
/**
87+
* Instrument selection criteria:
88+
* The unit of the Instrument(s).
89+
*
90+
* @example <caption>select all instruments with unit 'ms'</caption>
91+
* instrumentUnit: 'ms'
92+
*/
93+
instrumentUnit?: string;
8694
/**
8795
* Instrument selection criteria:
8896
* The name of the Meter. No wildcard support, name must match the meter exactly.
@@ -113,6 +121,7 @@ function isSelectorNotProvided(options: ViewOptions): boolean {
113121
return (
114122
options.instrumentName == null &&
115123
options.instrumentType == null &&
124+
options.instrumentUnit == null &&
116125
options.meterName == null &&
117126
options.meterVersion == null &&
118127
options.meterSchemaUrl == null
@@ -161,6 +170,9 @@ export class View {
161170
* @param viewOptions.instrumentType
162171
* Instrument selection criteria:
163172
* The original type of the Instrument(s).
173+
* @param viewOptions.instrumentUnit
174+
* Instrument selection criteria:
175+
* The unit of the Instrument(s).
164176
* @param viewOptions.meterName
165177
* Instrument selection criteria:
166178
* The name of the Meter. No wildcard support, name must match the meter exactly.
@@ -213,6 +225,7 @@ export class View {
213225
this.instrumentSelector = new InstrumentSelector({
214226
name: viewOptions.instrumentName,
215227
type: viewOptions.instrumentType,
228+
unit: viewOptions.instrumentUnit,
216229
});
217230
this.meterSelector = new MeterSelector({
218231
name: viewOptions.meterName,

packages/sdk-metrics/src/view/ViewRegistry.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export class ViewRegistry {
4848
return (
4949
(selector.getType() === undefined ||
5050
instrument.type === selector.getType()) &&
51-
selector.getNameFilter().match(instrument.name)
51+
selector.getNameFilter().match(instrument.name) &&
52+
selector.getUnitFilter().match(instrument.unit)
5253
);
5354
}
5455

packages/sdk-metrics/test/MeterProvider.test.ts

+71-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515
*/
1616

1717
import * as assert from 'assert';
18-
import { MeterProvider, InstrumentType, DataPointType } from '../src';
18+
import {
19+
MeterProvider,
20+
InstrumentType,
21+
DataPointType,
22+
ExplicitBucketHistogramAggregation,
23+
HistogramMetricData,
24+
} from '../src';
1925
import {
2026
assertScopeMetrics,
2127
assertMetricData,
@@ -463,6 +469,70 @@ describe('MeterProvider', () => {
463469
}
464470
);
465471
});
472+
473+
it('with instrument unit should apply view to only the selected instrument unit', async () => {
474+
// Add views with different boundaries for each unit.
475+
const msBoundaries = [0, 1, 2, 3, 4, 5];
476+
const sBoundaries = [10, 50, 250, 1000];
477+
478+
const meterProvider = new MeterProvider({
479+
resource: defaultResource,
480+
views: [
481+
new View({
482+
instrumentUnit: 'ms',
483+
aggregation: new ExplicitBucketHistogramAggregation(msBoundaries),
484+
}),
485+
new View({
486+
instrumentUnit: 's',
487+
aggregation: new ExplicitBucketHistogramAggregation(sBoundaries),
488+
}),
489+
],
490+
});
491+
492+
const reader = new TestMetricReader();
493+
meterProvider.addMetricReader(reader);
494+
495+
// Create meter and histograms, with different units.
496+
const meter = meterProvider.getMeter('meter1', 'v1.0.0');
497+
const histogram1 = meter.createHistogram('test-histogram-ms', {
498+
unit: 'ms',
499+
});
500+
const histogram2 = meter.createHistogram('test-histogram-s', {
501+
unit: 's',
502+
});
503+
504+
// Record values for both.
505+
histogram1.record(1);
506+
histogram2.record(1);
507+
508+
// Perform collection.
509+
const { resourceMetrics, errors } = await reader.collect();
510+
511+
assert.strictEqual(errors.length, 0);
512+
// Results came only from one Meter
513+
assert.strictEqual(resourceMetrics.scopeMetrics.length, 1);
514+
515+
// InstrumentationScope matches the only created Meter.
516+
assertScopeMetrics(resourceMetrics.scopeMetrics[0], {
517+
name: 'meter1',
518+
version: 'v1.0.0',
519+
});
520+
521+
// Two metrics are collected ('test-histogram-ms' and 'test-histogram-s')
522+
assert.strictEqual(resourceMetrics.scopeMetrics[0].metrics.length, 2);
523+
524+
// Check if the boundaries are applied to the correct instrument.
525+
assert.deepStrictEqual(
526+
(resourceMetrics.scopeMetrics[0].metrics[0] as HistogramMetricData)
527+
.dataPoints[0].value.buckets.boundaries,
528+
msBoundaries
529+
);
530+
assert.deepStrictEqual(
531+
(resourceMetrics.scopeMetrics[0].metrics[1] as HistogramMetricData)
532+
.dataPoints[0].value.buckets.boundaries,
533+
sBoundaries
534+
);
535+
});
466536
});
467537

468538
describe('shutdown', () => {

packages/sdk-metrics/test/view/ViewRegistry.test.ts

+44
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,50 @@ describe('ViewRegistry', () => {
101101
assert.strictEqual(views[0].name, 'histogram');
102102
}
103103
});
104+
105+
it('should match view with instrument unit', () => {
106+
const registry = new ViewRegistry();
107+
registry.addView(
108+
new View({
109+
name: 'ms_view',
110+
instrumentName: 'default_metric',
111+
instrumentUnit: 'ms',
112+
})
113+
);
114+
registry.addView(
115+
new View({
116+
name: 's_view',
117+
instrumentName: 'default_metric',
118+
instrumentUnit: 's',
119+
})
120+
);
121+
122+
{
123+
const views = registry.findViews(
124+
{
125+
...defaultInstrumentDescriptor,
126+
unit: 'ms',
127+
},
128+
defaultInstrumentationScope
129+
);
130+
131+
assert.strictEqual(views.length, 1);
132+
assert.strictEqual(views[0].name, 'ms_view');
133+
}
134+
135+
{
136+
const views = registry.findViews(
137+
{
138+
...defaultInstrumentDescriptor,
139+
unit: 's',
140+
},
141+
defaultInstrumentationScope
142+
);
143+
144+
assert.strictEqual(views.length, 1);
145+
assert.strictEqual(views[0].name, 's_view');
146+
}
147+
});
104148
});
105149

106150
describe('MeterSelector', () => {

scripts/update-ts-configs.js

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const ignoredLernaProjects = [
5050
'selenium-tests',
5151
'examples/otlp-exporter-node',
5252
'examples/opentelemetry-web',
53+
'examples/http',
5354
'examples/https',
5455
];
5556

0 commit comments

Comments
 (0)