Skip to content

Commit

Permalink
Merge branch 'open-telemetry:main' into entity-prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan authored Dec 12, 2024
2 parents 2d995c6 + e4d9c21 commit c1135eb
Show file tree
Hide file tree
Showing 29 changed files with 330 additions and 591 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
cache: 'npm'
cache-dependency-path: |
package-lock.json
node-version: 16
node-version: 22

- name: Bootstrap
run: npm ci
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
cache: 'npm'
cache-dependency-path: |
package-lock.json
node-version: 16
node-version: 22

- name: Bootstrap
run: npm ci
Expand Down
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se

### :rocket: (Enhancement)

* feat(sdk-metrics): PeriodicExportingMetricReader now flushes pending tasks at shutdown [#5242](https://github.com/open-telemetry/opentelemetry-js/pull/5242)

### :bug: (Bug Fix)

* fix(sdk-trace-base): do not load OTEL_ env vars on module load, but when needed [#5224](https://github.com/open-telemetry/opentelemetry-js/pull/5224)

* fix(instrumentation-xhr, instrumentation-fetch): content length attributes no longer get removed with `ignoreNetworkEvents: true` being set [#5229](https://github.com/open-telemetry/opentelemetry-js/issues/5229)

### :books: (Refine Doc)

### :house: (Internal)

## 1.29.0

### :boom: Breaking Change
### :rocket: (Enhancement)

* feat(sdk-metrics): Add support for aggregation cardinality limit with a default limit of 2000. This limit can be customized via views [#5182](https://github.com/open-telemetry/opentelemetry-js/pull/5128)
* feat(sdk-metrics): Add support for aggregation cardinality limit with a default limit of 2000. This limit can be customized via views [#5128](https://github.com/open-telemetry/opentelemetry-js/pull/5128)

## 1.28.0

Expand Down
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,25 @@ All stable packages are released with the same version, and all experimental pac
The below table describes which versions of each set of packages are expected to work together.

| Stable Packages | Experimental Packages |
| --------------- | --------------------- |
| 1.21.x | 0.48.x |
| 1.20.x | 0.47.x |
| 1.19.x | 0.46.x |
| 1.18.x | 0.45.x |
| 1.17.x | 0.44.x |
|-----------------|-----------------------|
| 1.29.x | 0.56.x |
| 1.28.x | 0.55.x |
| 1.27.x | 0.54.x |
| 1.25.x | 0.52.x |
| 1.24.x | 0.51.x |

<details>
<summary>Older version compatibility matrix</summary>

<table>
<tr><th>Stable Packages</th> <th>Experimental Packages</th></tr>
<tr><td>1.23.x</td> <td>0.50.x</td></tr>
<tr><td>1.22.x</td> <td>0.49.x</td></tr>
<tr><td>1.21.x</td> <td>0.48.x</td></tr>
<tr><td>1.20.x</td> <td>0.47.x</td></tr>
<tr><td>1.19.x</td> <td>0.46.x</td></tr>
<tr><td>1.18.x</td> <td>0.45.x</td></tr>
<tr><td>1.17.x</td> <td>0.43.x, 0.44.x</td></tr>
<tr><td>1.16.x</td> <td>0.42.x</td></tr>
<tr><td>1.15.x</td> <td>0.41.x</td></tr>
<tr><td>1.14.x</td> <td>0.40.x</td></tr>
Expand Down
6 changes: 3 additions & 3 deletions api/test/tree-shaking/tree-shaking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import * as realFs from 'fs';
* Webpack doesn't run in node 8 because it requires BigInt. Since we are testing
* build tooling here, we can safely skip tooling we know can't run anyway.
*/
describe('tree-shaking', () => {
describe('tree-shaking', function () {
const allowedAPIs = ['ContextAPI', 'DiagAPI'];
const testAPIs = [
{
Expand All @@ -50,7 +50,7 @@ describe('tree-shaking', () => {
const outputPath = path.join(__dirname, 'output');
const outputFilename = path.join(outputPath, 'bundle.js');

afterEach(() => {
afterEach(function () {
try {
mfs.unlinkSync(outputFilename);
} catch {
Expand Down Expand Up @@ -122,6 +122,6 @@ describe('tree-shaking', () => {
allowedAPIs.forEach(it => matches.delete(it));

assert.deepStrictEqual(Array.from(matches), [testAPI.name]);
});
}).timeout(5000);
}
});
54 changes: 54 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,60 @@ All notable changes to experimental packages in this project will be documented
* feat(otlp-transformer)!: accept `ResourceMetrics` in serializers instead of `ResourceMetrics[]`
* (user-facing): `ProtobufMetricsSerializer` now only accepts `ResourceMetrics` instead of `ResourceMetrics[]` to align with `PushMetricExporter` requirements
* (user-facing): `JsonMetricsSerializer` now only accepts `ResourceMetrics` instead of `ResourceMetrics[]` to align with `PushMetricExporter` requirements
* feat(otlp-transformer)!: remove internal types and functions from public API @pichlermarc
* (user-facing): the following types and functions were intended for internal use and have been removed from exports
* `OtlpEncodingOptions`
* `IKeyValueList`
* `IKeyValue`
* `IInstrumentationScope`
* `IArrayValue`
* `LongBits`
* `IAnyValue`
* `Fixed64`
* `SpanContextEncodeFunction`
* `toLongBits`
* `OptionalSpanContextEncodeFunction`
* `getOtlpEncoder`
* `Encoder`
* `HrTimeEncodeFunction`
* `encodeAsLongBits`
* `encodeAsString`
* `hrTimeToNanos`
* `IValueAtQuantile`
* `ISummaryDataPoint`
* `ISummary`
* `ISum`
* `IScopeMetrics`
* `IResourceMetrics`
* `INumberDataPoint`
* `IHistogramDataPoint`
* `IHistogram`
* `IExponentialHistogramDataPoint`
* `IExponentialHistogram`
* `IMetric`
* `IGauge`
* `IExemplar`
* `EAggregationTemporality`
* `IExportMetricsServiceRequest`
* `IBuckets`
* `IResource`
* `IStatus`
* `EStatusCode`
* `ILink`
* `IEvent`
* `IScopeSpans`
* `ISpan`
* `IResourceSpans`
* `ESpanKind`
* `IExportTraceServiceRequest`
* `IScopeLogs`
* `IExportLogsServiceRequest`
* `IResourceLogs`
* `ILogRecord`
* `ESeverityNumber`
* `createExportTraceServiceRequest`
* `createExportMetricsServiceRequest`
* `createExportLogsServiceRequest`

### :rocket: (Enhancement)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ describe('OTLPMetricExporter', () => {
meterProvider.getMeter('test-meter').createCounter('test-counter').add(1);

// act
meterProvider.forceFlush();
meterProvider.shutdown();
meterProvider.forceFlush().then(() => {
return meterProvider.shutdown();
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ export class FetchInstrumentation extends InstrumentationBase<FetchInstrumentati
},
api.trace.setSpan(api.context.active(), span)
);
if (!this.getConfig().ignoreNetworkEvents) {
web.addSpanNetworkEvents(childSpan, corsPreFlightRequest);
}
web.addSpanNetworkEvents(
childSpan,
corsPreFlightRequest,
this.getConfig().ignoreNetworkEvents
);
childSpan.end(
corsPreFlightRequest[web.PerformanceTimingNames.RESPONSE_END]
);
Expand Down Expand Up @@ -262,9 +264,11 @@ export class FetchInstrumentation extends InstrumentationBase<FetchInstrumentati
this._addChildSpan(span, corsPreFlightRequest);
this._markResourceAsUsed(corsPreFlightRequest);
}
if (!this.getConfig().ignoreNetworkEvents) {
web.addSpanNetworkEvents(span, mainRequest);
}
web.addSpanNetworkEvents(
span,
mainRequest,
this.getConfig().ignoreNetworkEvents
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1212,5 +1212,18 @@ describe('fetch', () => {
const events = span.events;
assert.strictEqual(events.length, 0, 'number of events is wrong');
});

it('should still add the CONTENT_LENGTH attribute', () => {
const span: tracing.ReadableSpan = exportSpy.args[1][0][0];
const attributes = span.attributes;
const responseContentLength = attributes[
SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH
] as number;
assert.strictEqual(
responseContentLength,
30,
`attributes ${SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH} is <= 0`
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase<XMLHttpRe
const childSpan = this.tracer.startSpan('CORS Preflight', {
startTime: corsPreFlightRequest[PTN.FETCH_START],
});
if (!this.getConfig().ignoreNetworkEvents) {
addSpanNetworkEvents(childSpan, corsPreFlightRequest);
}
addSpanNetworkEvents(
childSpan,
corsPreFlightRequest,
this.getConfig().ignoreNetworkEvents
);
childSpan.end(corsPreFlightRequest[PTN.RESPONSE_END]);
});
}
Expand Down Expand Up @@ -300,9 +302,11 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase<XMLHttpRe
this._addChildSpan(span, corsPreFlightRequest);
this._markResourceAsUsed(corsPreFlightRequest);
}
if (!this.getConfig().ignoreNetworkEvents) {
addSpanNetworkEvents(span, mainRequest);
}
addSpanNetworkEvents(
span,
mainRequest,
this.getConfig().ignoreNetworkEvents
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,19 @@ describe('xhr', () => {
const events = span.events;
assert.strictEqual(events.length, 3, 'number of events is wrong');
});

it('should still add the CONTENT_LENGTH attribute', () => {
const span: tracing.ReadableSpan = exportSpy.args[1][0][0];
const attributes = span.attributes;
const responseContentLength = attributes[
SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH
] as number;
assert.strictEqual(
responseContentLength,
30,
`attributes ${SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH} is <= 0`
);
});
});
});

Expand Down
37 changes: 30 additions & 7 deletions experimental/packages/otlp-transformer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,41 @@ npm install @opentelemetry/api

### Serialize Traces/Metrics/Logs

This module exports functions to serialize traces, metrics and logs from the OpenTelemetry SDK into protocol buffers which can be sent over HTTP to the OpenTelemetry collector or a compatible receiver.
This module exports serializers to serialize traces, metrics and logs from the OpenTelemetry SDK into protocol buffers
or JSON which can be sent over HTTP or gRPC (protobuf-only) to the OpenTelemetry collector or a compatible receiver.

```typescript
import {
createExportTraceServiceRequest,
createExportMetricsServiceRequest,
createExportLogsServiceRequest,
JsonLogsSerializer,
JsonMetricsSerializer,
JsonTraceSerializer,
ProtobufLogsSerializer,
ProtobufMetricsSerializer,
ProtobufTraceSerializer,
IExportLogsServiceResponse,
IExportMetricsServiceResponse,
IExportTraceServiceResponse,
} from '@opentelemetry/otlp-transformer';

const serializedSpans = createExportTraceServiceRequest(readableSpans);
const serializedMetrics = createExportMetricsServiceRequest(readableMetrics);
const serializedLogs = createExportLogsServiceRequest(readableLogRecords);
// serialize to JSON export requests
const serializedJsonLogs: Uint8Array = JsonLogsSerializer.serializeRequest(readableLogRecords);
const serializedJsonMetrics: Uint8Array = JsonMetricsSerializer.serializeRequest(resourceMetrics);
const serializedJsonTraces: Uint8Array = JsonTraceSerializer.serializeRequest(readableSpans);

// serialize to Protobuf export requests
const serializedProtobufLogs: Uint8Array = ProtobufLogsSerializer.serializeRequest(readableLogRecords);
const serializedProtobufMetrics: Uint8Array = ProtobufMetricsSerializer.serializeRequest(resourceMetrics);
const serializedProtobufTraces: Uint8Array = ProtobufTraceSerializer.serializeRequest(readableSpans);

// deserialize JSON export responses
const deserializedJsonLogResponse: IExportLogsServiceResponse = JsonLogsSerializer.deserializeResponse(jsonLogResponse);
const deserializedJsonMetricsResponse: IExportMetricsServiceResponse = JsonMetricsSerializer.deserializeResponse(jsonMetricsResponse);
const deserializedJsonTraceResponse: IExportTraceServiceResponse = JsonTraceSerializer.deserializeResponse(jsonTraceResponse);

// deserialize Protobuf export responses
const deserializedProtobufLogResponse: IExportLogsServiceResponse = ProtobufLogsSerializer.deserializeResponse(protobufLogResponse);
const deserializedProtobufMetricsResponse: IExportMetricsServiceResponse = ProtobufMetricsSerializer.deserializeResponse(protobufMetricsResponse);
const deserializedProtobufTraceResponse: IExportTraceServiceResponse = ProtobufTraceSerializer.deserializeResponse(protobufTraceResponse);
```

## Useful links
Expand Down
57 changes: 0 additions & 57 deletions experimental/packages/otlp-transformer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,76 +14,19 @@
* limitations under the License.
*/

export {
OtlpEncodingOptions,
IKeyValueList,
IKeyValue,
IInstrumentationScope,
IArrayValue,
LongBits,
IAnyValue,
Fixed64,
} from './common/types';
export {
SpanContextEncodeFunction,
toLongBits,
OptionalSpanContextEncodeFunction,
getOtlpEncoder,
Encoder,
HrTimeEncodeFunction,
encodeAsLongBits,
encodeAsString,
hrTimeToNanos,
} from './common';
export {
IExportMetricsPartialSuccess,
IValueAtQuantile,
ISummaryDataPoint,
ISummary,
ISum,
IScopeMetrics,
IResourceMetrics,
INumberDataPoint,
IHistogramDataPoint,
IHistogram,
IExponentialHistogramDataPoint,
IExponentialHistogram,
IMetric,
IGauge,
IExemplar,
EAggregationTemporality,
IExportMetricsServiceRequest,
IExportMetricsServiceResponse,
IBuckets,
} from './metrics/types';
export { IResource } from './resource/types';
export {
IExportTracePartialSuccess,
IStatus,
EStatusCode,
ILink,
IEvent,
IScopeSpans,
ISpan,
IResourceSpans,
ESpanKind,
IExportTraceServiceResponse,
IExportTraceServiceRequest,
} from './trace/types';
export {
IExportLogsServiceResponse,
IScopeLogs,
IExportLogsServiceRequest,
IResourceLogs,
ILogRecord,
IExportLogsPartialSuccess,
ESeverityNumber,
} from './logs/types';

export { createExportTraceServiceRequest } from './trace';
export { createExportMetricsServiceRequest } from './metrics';
export { createExportLogsServiceRequest } from './logs';

export {
ProtobufLogsSerializer,
ProtobufMetricsSerializer,
Expand Down
Loading

0 comments on commit c1135eb

Please sign in to comment.