Skip to content

Commit

Permalink
Merge branch 'main' into fix/exporter-concurrency-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc authored Nov 14, 2023
2 parents 0477ba6 + b0c0ace commit 2374b33
Show file tree
Hide file tree
Showing 23 changed files with 237 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '18'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16'

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}

Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '18'

Expand All @@ -83,7 +83,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 16

Expand All @@ -104,7 +104,7 @@ jobs:
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 16

Expand All @@ -131,7 +131,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/w3c-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Checkout 🛎️
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16'

Expand Down
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/

### :boom: Breaking Change

* 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

### :rocket: (Enhancement)

### :books: (Refine Doc)

### :house: (Internal)

* chore: type reference on zone.js [#4257](https://github.com/open-telemetry/opentelemetry-js/pull/4257) @legendecas
* chore: no need for 'packages' in lerna.json [#4264](https://github.com/open-telemetry/opentelemetry-js/pull/4264) @trentm

### :bug: (Bug Fix)

* 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

## 1.18.1

### :bug: (Bug Fix)
Expand Down
2 changes: 2 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ All notable changes to experimental packages in this project will be documented

### :bug: (Bug Fix)

* fix(sdk-logs): avoid map attribute set when count limit exceeded

### :books: (Refine Doc)

### :house: (Internal)
Expand Down
22 changes: 16 additions & 6 deletions experimental/examples/prometheus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,28 @@ This is a simple example that demonstrates basic metrics collection and exports
npm install
```

Setup [Prometheus](https://prometheus.io/docs/prometheus/latest/getting_started/)

## Run the Application

- Run the server

```sh
# from this directory
npm run start
```

If you are using the default configurations, the metrics should be available at <http://localhost:9464/metrics>

## Run Prometheus

### With docker

```sh
# from this directory
docker compose up
```

### With binary

Setup [Prometheus](https://prometheus.io/docs/prometheus/latest/getting_started/)

- Replace the `prometheus.yml` provided by the Prometheus installation with the following:

```yaml
Expand All @@ -34,7 +45,6 @@ scrape_configs:
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9464']

```
- Start Prometheus
Expand All @@ -44,7 +54,7 @@ scrape_configs:
prometheus --config.file=prometheus.yml
```

### Prometheus UI
## Prometheus UI

If you are using the default configurations, the prometheus client will be available at <http://localhost:9090>

Expand Down
12 changes: 12 additions & 0 deletions experimental/examples/prometheus/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.7'

services:
prometheus:
image: prom/prometheus:v2.47.2
extra_hosts:
- host.docker.internal:host-gateway
volumes:
- "./prometheus.docker.yml:/etc/prometheus/prometheus.yml"
ports:
- 9090:9090
restart: always
9 changes: 9 additions & 0 deletions experimental/examples/prometheus/prometheus.docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
global:
scrape_interval: 15s # Default is every 1 minute.

scrape_configs:
- job_name: 'opentelemetry'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['host.docker.internal:9464']
1 change: 1 addition & 0 deletions experimental/packages/otlp-transformer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"tdd": "npm run test -- --watch-extensions ts --watch",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"test:browser": "karma start --single-run",
"test:bench": "node test/performance/benchmark/index.js | tee .benchmark-results.txt",
"prewatch": "node ../../../scripts/version-update.js",
"watch": "tsc --build -w tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"peer-api-check": "node ../../../scripts/peer-api-check.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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 Benchmark = require('benchmark');
const { createExportTraceServiceRequest } = require('../../../build/src');
const { BasicTracerProvider } = require('@opentelemetry/sdk-trace-base');

const tracerProvider = new BasicTracerProvider();
const tracer = tracerProvider.getTracer('test')

const suite = new Benchmark.Suite();

const span = createSpan();
const spans = [];
for (let i = 0; i < 100; i++) {
spans.push(createSpan());
}

suite.on('cycle', event => {
console.log(String(event.target));
});

suite.add('transform 1 span', function() {
createExportTraceServiceRequest([span]);
});

suite.add('transform 100 spans', function() {
createExportTraceServiceRequest(spans);
});

suite.run();

function createSpan() {
const span = tracer.startSpan('span');
span.setAttribute('aaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaa');
span.setAttribute('bbbbbbbbbbbbbbbbbbbb', 'bbbbbbbbbbbbbbbbbbbb');
span.setAttribute('cccccccccccccccccccc', 'cccccccccccccccccccc');
span.setAttribute('dddddddddddddddddddd', 'dddddddddddddddddddd');
span.setAttribute('eeeeeeeeeeeeeeeeeeee', 'eeeeeeeeeeeeeeeeeeee');
span.setAttribute('ffffffffffffffffffff', 'ffffffffffffffffffff');
span.setAttribute('gggggggggggggggggggg', 'gggggggggggggggggggg');
span.setAttribute('hhhhhhhhhhhhhhhhhhhh', 'hhhhhhhhhhhhhhhhhhhh');
span.setAttribute('iiiiiiiiiiiiiiiiiiii', 'iiiiiiiiiiiiiiiiiiii');
span.setAttribute('jjjjjjjjjjjjjjjjjjjj', 'jjjjjjjjjjjjjjjjjjjj');
span.end();

return span;
}
22 changes: 13 additions & 9 deletions experimental/packages/sdk-logs/src/LogRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,18 @@ export class LogRecord implements ReadableLogRecord {
if (value === null) {
return this;
}
if (
typeof value === 'object' &&
!Array.isArray(value) &&
Object.keys(value).length > 0
) {
this.attributes[key] = value;
}
if (key.length === 0) {
api.diag.warn(`Invalid attribute key: ${key}`);
return this;
}
if (!isAttributeValue(value)) {
if (
!isAttributeValue(value) &&
!(
typeof value === 'object' &&
!Array.isArray(value) &&
Object.keys(value).length > 0
)
) {
api.diag.warn(`Invalid attribute value set for key: ${key}`);
return this;
}
Expand All @@ -136,7 +136,11 @@ export class LogRecord implements ReadableLogRecord {
) {
return this;
}
this.attributes[key] = this._truncateToSize(value);
if (isAttributeValue(value)) {
this.attributes[key] = this._truncateToSize(value);
} else {
this.attributes[key] = value;
}
return this;
}

Expand Down
26 changes: 24 additions & 2 deletions experimental/packages/sdk-logs/test/common/LogRecord.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,36 @@ describe('LogRecord', () => {
describe('when "attributeCountLimit" option defined', () => {
const { logRecord } = setup({ attributeCountLimit: 100 });
for (let i = 0; i < 150; i++) {
logRecord.setAttribute(`foo${i}`, `bar${i}`);
let attributeValue;
switch (i % 3) {
case 0: {
attributeValue = `bar${i}`;
break;
}
case 1: {
attributeValue = [`bar${i}`];
break;
}
case 2: {
attributeValue = {
bar: `bar${i}`,
};
break;
}
default: {
attributeValue = `bar${i}`;
}
}
logRecord.setAttribute(`foo${i}`, attributeValue);
}

it('should remove / drop all remaining values after the number of values exceeds this limit', () => {
const { attributes } = logRecord;
assert.strictEqual(Object.keys(attributes).length, 100);
assert.strictEqual(attributes.foo0, 'bar0');
assert.strictEqual(attributes.foo99, 'bar99');
assert.deepStrictEqual(attributes.foo98, { bar: 'bar98' });
assert.strictEqual(attributes.foo147, undefined);
assert.strictEqual(attributes.foo148, undefined);
assert.strictEqual(attributes.foo149, undefined);
});
});
Expand Down
Loading

0 comments on commit 2374b33

Please sign in to comment.