node-telemetry-trace 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ name: CI
2
+ on: [push, pull_request]
3
+ jobs:
4
+ test:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - uses: actions/checkout@v4
8
+ - uses: actions/setup-node@v4
9
+ with:
10
+ node-version: '20'
11
+ - run: npm ci
12
+ - run: npm test
13
+ - run: npm run build
package/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ ## [1.1.0] - 2026-01-31
4
+ ### Added
5
+ - Context propagation
6
+ - Console exporter
7
+ - Docker setup with Jaeger
8
+ - CI/CD pipeline
9
+ - Enhanced documentation
10
+
11
+ ## [1.0.0] - 2026-01-31
12
+ - Initial release
@@ -0,0 +1,12 @@
1
+ # Contributing
2
+
3
+ ## Setup
4
+ ```bash
5
+ npm install
6
+ npm test
7
+ ```
8
+
9
+ ## Guidelines
10
+ - Write tests for new features
11
+ - Follow code style
12
+ - Update docs
@@ -0,0 +1,7 @@
1
+ import { Span } from '../interfaces/span.interface';
2
+ export declare class TracingContext {
3
+ private static contexts;
4
+ static setSpan(key: string, span: Span): void;
5
+ static getSpan(key: string): Span | undefined;
6
+ static clear(key: string): void;
7
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TracingContext = void 0;
4
+ class TracingContext {
5
+ static setSpan(key, span) {
6
+ this.contexts.set(key, span);
7
+ }
8
+ static getSpan(key) {
9
+ return this.contexts.get(key);
10
+ }
11
+ static clear(key) {
12
+ this.contexts.delete(key);
13
+ }
14
+ }
15
+ exports.TracingContext = TracingContext;
16
+ TracingContext.contexts = new Map();
@@ -0,0 +1,4 @@
1
+ import { Span } from '../interfaces/span.interface';
2
+ export declare class ConsoleExporter {
3
+ export(span: Span): void;
4
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsoleExporter = void 0;
4
+ class ConsoleExporter {
5
+ export(span) {
6
+ console.log('[Trace]', {
7
+ traceId: span.traceId,
8
+ spanId: span.spanId,
9
+ operation: span.operationName,
10
+ duration: span.endTime ? span.endTime.getTime() - span.startTime.getTime() : 0,
11
+ tags: span.tags,
12
+ });
13
+ }
14
+ }
15
+ exports.ConsoleExporter = ConsoleExporter;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const console_exporter_1 = require("./console.exporter");
4
+ describe('ConsoleExporter', () => {
5
+ let exporter;
6
+ beforeEach(() => {
7
+ exporter = new console_exporter_1.ConsoleExporter();
8
+ });
9
+ it('should export span to console', () => {
10
+ const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
11
+ const span = {
12
+ spanId: '123',
13
+ traceId: '456',
14
+ operationName: 'test-op',
15
+ startTime: new Date(),
16
+ endTime: new Date(),
17
+ tags: {},
18
+ end: jest.fn(),
19
+ };
20
+ exporter.export(span);
21
+ expect(consoleSpy).toHaveBeenCalled();
22
+ consoleSpy.mockRestore();
23
+ });
24
+ });
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from './services/tracing.service';
2
2
  export * from './interfaces/span.interface';
3
+ export * from './context/context';
4
+ export * from './exporters/console.exporter';
package/dist/index.js CHANGED
@@ -16,3 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./services/tracing.service"), exports);
18
18
  __exportStar(require("./interfaces/span.interface"), exports);
19
+ __exportStar(require("./context/context"), exports);
20
+ __exportStar(require("./exporters/console.exporter"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-telemetry-trace",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Distributed tracing and observability SDK for Node.js applications with OpenTelemetry integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/jest.config.js DELETED
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- moduleFileExtensions: ['js', 'json', 'ts'],
3
- rootDir: 'src',
4
- testRegex: '.*\\.spec\\.ts$',
5
- transform: { '^.+\\.(t|j)s$': 'ts-jest' },
6
- testEnvironment: 'node',
7
- };
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './services/tracing.service';
2
- export * from './interfaces/span.interface';
@@ -1,14 +0,0 @@
1
- export interface Span {
2
- spanId: string;
3
- traceId: string;
4
- operationName: string;
5
- startTime: Date;
6
- endTime?: Date;
7
- tags: Record<string, any>;
8
- end(): void;
9
- }
10
-
11
- export interface TracingOptions {
12
- serviceName: string;
13
- sampleRate?: number;
14
- }
@@ -1,22 +0,0 @@
1
- import { TracingService } from './tracing.service';
2
-
3
- describe('TracingService', () => {
4
- let service: TracingService;
5
-
6
- beforeEach(() => {
7
- service = new TracingService({ serviceName: 'test-service' });
8
- });
9
-
10
- it('should create spans', () => {
11
- const span = service.startSpan('test-operation');
12
- expect(span).toBeDefined();
13
- expect(span.operationName).toBe('test-operation');
14
- expect(span.spanId).toBeDefined();
15
- });
16
-
17
- it('should end spans', () => {
18
- const span = service.startSpan('test-operation');
19
- span.end();
20
- expect(span.endTime).toBeDefined();
21
- });
22
- });
@@ -1,23 +0,0 @@
1
- import { Span, TracingOptions } from '../interfaces/span.interface';
2
-
3
- export class TracingService {
4
- constructor(private options: TracingOptions) {}
5
-
6
- startSpan(operationName: string): Span {
7
- const span: Span = {
8
- spanId: this.generateId(),
9
- traceId: this.generateId(),
10
- operationName,
11
- startTime: new Date(),
12
- tags: {},
13
- end: function() {
14
- this.endTime = new Date();
15
- },
16
- };
17
- return span;
18
- }
19
-
20
- private generateId(): string {
21
- return Math.random().toString(36).substring(7);
22
- }
23
- }
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "declaration": true,
5
- "target": "ES2021",
6
- "outDir": "./dist",
7
- "skipLibCheck": true
8
- },
9
- "include": ["src/**/*"]
10
- }