Skip to content

Commit

Permalink
Merge branch 'main' of github.com:zonneplan/open-telemetry-js
Browse files Browse the repository at this point in the history
  • Loading branch information
rtuin committed Oct 8, 2024
2 parents e37a6e2 + 0a18599 commit 881e5d2
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 83 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ jobs:
run: |
git add .
git commit -m "chore(release): bump version to ${{ steps.get_tag.outputs.tag }}"
git tag -a ${{ steps.get_tag.outputs.tag }} -m "chore(release): ${{ steps.get_tag.outputs.tag }}"
git push
git tag ${{ steps.get_tag.outputs.tag }}
git push origin ${{ steps.get_tag.outputs.tag }}
# Order matters for the publishing, packages with dependencies should be published last
- name: Publish package
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [1.1.0](https://github.com/zonneplan/open-telemetry-js/compare/v1.0.2...v1.1.0) (2024-10-08)


### Features

* use diag error logging for uninitialized providers ([577e1d4](https://github.com/zonneplan/open-telemetry-js/commit/577e1d47578616c62d0514709144b3d704f3bd63))

## [1.0.2](https://github.com/zonneplan/open-telemetry-js/compare/v1.0.1...v1.0.2) (2024-10-03)

## [1.0.1](https://github.com/zonneplan/open-telemetry-js/compare/v1.0.0...v1.0.1) (2024-10-03)

## [1.0.0](https://github.com/zonneplan/open-telemetry-js/compare/v0.1.0...v1.0.0) (2024-07-05)


Expand Down
2 changes: 1 addition & 1 deletion libs/dependency-syncer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zonneplan/dependency-syncer",
"version": "1.0.0",
"version": "1.1.0",
"dependencies": {
"@nx/devkit": "18.0.8",
"tslib": "^2.3.0"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zonneplan/open-telemetry-js",
"version": "1.0.0",
"version": "1.1.0",
"license": "MIT",
"scripts": {
"prepare": "([ \"$NODE_ENV\" = \"production\" ] || husky .git-hooks)"
Expand Down
4 changes: 2 additions & 2 deletions packages/open-telemetry-nest/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@zonneplan/open-telemetry-nest",
"license": "MIT",
"version": "1.0.0",
"version": "1.1.0",
"dependencies": {
"@nestjs/common": "^10.3.10",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/api-logs": "^0.52.1",
"@opentelemetry/exporter-prometheus": "^0.52.1",
"@opentelemetry/sdk-metrics": "^1.25.1",
"@zonneplan/open-telemetry-node": "^1.0.0",
"@zonneplan/open-telemetry-node": "^1.1.0",
"prom-client": "^15.1.3",
"tslib": "^2.6.3",
"winston": "^3.13.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Logger } from 'winston';
import { GlobalProviders } from '@zonneplan/open-telemetry-node';
import { LogAttributes, SeverityNumber } from '@opentelemetry/api-logs';
import { LoggerService } from '../services/logger.service';
import { context } from '@opentelemetry/api';
import { context, diag } from '@opentelemetry/api';
import {
NEST_LOG_LEVEL_WINSTON_SEVERITY,
SEVERITY_NUMBER_TO_TEXT_MAP,
Expand Down Expand Up @@ -126,7 +126,7 @@ export class NestWinstonLoggerAdapter extends LoggerService {
}

if (!GlobalProviders.logProvider) {
console.error('OpenTelemetry log provider not initialized');
diag.error('OpenTelemetry log provider not initialized');
return;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/open-telemetry-node/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zonneplan/open-telemetry-node",
"license": "MIT",
"version": "1.0.0",
"version": "1.1.0",
"dependencies": {
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/api-logs": "^0.52.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ import { NodeSDK } from '@opentelemetry/sdk-node';
import { MeterProvider } from '@opentelemetry/sdk-metrics';

export interface IOpenTelemetryBuilder {
/**
* @deprecated - will be removed in v1.1, use {@link withDiagLogging} instead.
* for identical behaviour use `withDiagLogging(DiagLogLevel.DEBUG)`
*/
withDebugLogging(): this;

/**
* Enables diagnostic logging with the specified level.
* @param level
Expand Down Expand Up @@ -98,12 +92,6 @@ export class OpenTelemetryBuilder implements IOpenTelemetryBuilder {
return this;
}

/** @inheritdoc */
public withDebugLogging(): this {
this.diagLogLevel = DiagLogLevel.DEBUG;
return this;
}

public withLogging(
optionsBuilder: OptionsBuilderFn<IOpenTelemetryLoggingOptionsBuilder>
): this;
Expand Down
52 changes: 0 additions & 52 deletions packages/open-telemetry-node/src/metrics/metrics/gauge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,58 +24,6 @@ describe('Gauge', () => {
jest.useFakeTimers().setSystemTime(currentDate.getTime());
});

describe('set', () => {
it('should set the correct count and attributes when set is called', async () => {
// Arrange
const value = 5;
const attributes = { test: 'test' };

// Act
gauge?.set(value, attributes);

// Assert
const metrics = await getMetrics();
const metricDescriptor = metrics?.descriptor;
expect(metricDescriptor?.name).toEqual(metricName);

const dataPoints = metrics?.dataPoints;
expect(dataPoints).toHaveLength(1);

const gaugeData = dataPoints?.[0];
expect(gaugeData?.value).toEqual(value);
expect(gaugeData?.attributes).toEqual(attributes);
});

it('should set multiple data points for the same metric when set is called multiple times with different attributes', async () => {
// Arrange
const attributes2 = { test: 'test' };
const attributes3 = { test: 'test2' };

// Act
gauge?.set(1);
gauge?.set(2, attributes2);
gauge?.set(3, attributes3);

// Assert
const metrics = await getMetrics();
const metricDescriptor = metrics?.descriptor;
expect(metricDescriptor?.name).toEqual(metricName);

const dataPoints = metrics?.dataPoints;
expect(dataPoints).toHaveLength(3);

const [gaugeData, gaugeData2, gaugeData3] = dataPoints ?? [];
expect(gaugeData?.value).toEqual(1);
expect(gaugeData?.attributes).toEqual({});

expect(gaugeData2?.value).toEqual(2);
expect(gaugeData2?.attributes).toEqual(attributes2);

expect(gaugeData3?.value).toEqual(3);
expect(gaugeData3?.attributes).toEqual(attributes3);
});
});

describe('record', () => {
it('should set the correct count and attributes when set is called', async () => {
// Arrange
Expand Down
7 changes: 0 additions & 7 deletions packages/open-telemetry-node/src/metrics/metrics/gauge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ export class Gauge {
this.record(Date.now() / 1000, attributes);
}

/**
* @deprecated use {@link record} instead. Will be removed in version 1.1.
*/
public set(value: number, attributes?: Attributes): void {
this.gauge.record(value, attributes);
}

/**
* Records the value to the gauge.
* @param value the value to record.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { MetricOptions, MetricTypeMap } from '../models/metric-options.model';
import { GlobalProviders } from '../../globals';
import { diag } from '@opentelemetry/api';

/**
* Gets a metric if exists, otherwise creates a new metric.
Expand All @@ -12,7 +13,7 @@ export const getOrCreateMetric = <
options: MetricOptions<TMetricType>
): TMetric | null => {
if (!GlobalProviders.metricProvider) {
console.error('OpenTelemetry metrics are not initialized');
diag.error('OpenTelemetry metrics are not initialized');
return null;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/open-telemetry-zonneplan/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zonneplan/open-telemetry-zonneplan",
"license": "MIT",
"version": "1.0.0",
"version": "1.1.0",
"dependencies": {
"@nestjs/common": "^10.3.10",
"@opentelemetry/auto-instrumentations-node": "^0.47.1",
Expand All @@ -13,8 +13,8 @@
"@opentelemetry/instrumentation-winston": "^0.38.0",
"@opentelemetry/sdk-metrics": "^1.25.1",
"@opentelemetry/sdk-trace-base": "^1.25.1",
"@zonneplan/open-telemetry-nest": "^1.0.0",
"@zonneplan/open-telemetry-node": "^1.0.0",
"@zonneplan/open-telemetry-nest": "^1.1.0",
"@zonneplan/open-telemetry-node": "^1.1.0",
"opentelemetry-instrumentation-kafkajs": "^0.41.0",
"tslib": "^2.6.3",
"winston": "^3.13.0"
Expand Down

0 comments on commit 881e5d2

Please sign in to comment.