-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: http-fetch-utils-test adjusting new instrumentation dependency
- Loading branch information
1 parent
0524ccc
commit 07ac153
Showing
2 changed files
with
96 additions
and
13 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/core/infrastructure/observability/otel-tracer-provider.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Span, trace, Tracer } from '@opentelemetry/api' | ||
import { OtelTracerProvider } from './otel-tracer-provider' | ||
|
||
jest.mock('@opentelemetry/api', () => ({ | ||
trace: { | ||
getTracer: jest.fn().mockReturnValue({ | ||
startSpan: jest.fn().mockReturnValue({ | ||
end: jest.fn() | ||
}) | ||
}) | ||
} | ||
})) | ||
|
||
describe('OtelTracerProvider', () => { | ||
let otelTracerProvider: OtelTracerProvider | ||
let mockTracer: Tracer | ||
let mockSpan: Span | ||
|
||
beforeEach(() => { | ||
otelTracerProvider = new OtelTracerProvider() | ||
mockTracer = trace.getTracer('midaz-console') | ||
mockSpan = mockTracer.startSpan('test-span') | ||
}) | ||
|
||
it('should initialize otelTracer in the constructor', () => { | ||
expect(trace.getTracer).toHaveBeenCalledWith('midaz-console') | ||
}) | ||
|
||
it('should start a custom span', () => { | ||
const spanName = 'test-span' | ||
const span = otelTracerProvider.startCustomSpan(spanName) | ||
expect(mockTracer.startSpan).toHaveBeenCalledWith(spanName) | ||
expect(span).toBe(mockSpan) | ||
}) | ||
|
||
it('should end a custom span', () => { | ||
otelTracerProvider.endCustomSpan(mockSpan) | ||
expect(mockSpan.end).toHaveBeenCalled() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters