33const { expect } = require ( 'chai' )
44const { describe, it, before } = require ( 'mocha' )
55
6+ const assert = require ( 'node:assert' )
7+
8+ const LLMObsSDK = require ( '../../../dd-trace/src/llmobs/sdk' )
9+
10+ function getClassMethods ( clsProto , { ignore = [ ] } = { } ) {
11+ const ignoreList = new Set ( [ 'constructor' , ...[ ] . concat ( ignore ) ] )
12+ return Object . getOwnPropertyNames ( clsProto )
13+ . filter ( member => {
14+ if ( member . startsWith ( '_' ) || ignoreList . has ( member ) ) {
15+ return false
16+ }
17+
18+ const descriptor = Object . getOwnPropertyDescriptor ( clsProto , member )
19+ return descriptor && typeof descriptor . value === 'function'
20+ } )
21+ }
22+
623describe ( 'noop' , ( ) => {
724 let tracer
825 let llmobs
@@ -12,12 +29,54 @@ describe('noop', () => {
1229 llmobs = tracer . llmobs
1330 } )
1431
15- const nonTracingOps = [ 'enable' , 'disable' , 'annotate' , 'exportSpan' , 'submitEvaluation' , 'flush' ]
16- for ( const op of nonTracingOps ) {
17- it ( `using "${ op } " should not throw` , ( ) => {
18- llmobs [ op ] ( )
32+ it ( 'has all of the methods that the actual LLMObs SDK does' , ( ) => {
33+ assert . deepStrictEqual (
34+ getClassMethods ( LLMObsSDK . prototype ) . sort ( ) ,
35+ // the actual LLMObs SDK inherits the "decorate" method from the NoopLLMObs SDK
36+ // so we need to ignore it from the noop LLMObs SDK when comparing
37+ getClassMethods ( Object . getPrototypeOf ( llmobs ) , { ignore : [ 'decorate' ] } ) . sort ( )
38+ )
39+ } )
40+
41+ it ( 'using "enable" should not throw' , ( ) => {
42+ llmobs . enable ( )
43+ } )
44+
45+ it ( 'using "disable" should not throw' , ( ) => {
46+ llmobs . disable ( )
47+ } )
48+
49+ it ( 'using "annotate" should not throw' , ( ) => {
50+ llmobs . annotate ( )
51+ } )
52+
53+ it ( 'using "exportSpan" should not throw' , ( ) => {
54+ llmobs . exportSpan ( )
55+ } )
56+
57+ it ( 'using "submitEvaluation" should not throw' , ( ) => {
58+ llmobs . submitEvaluation ( )
59+ } )
60+
61+ it ( 'using "flush" should not throw' , ( ) => {
62+ llmobs . flush ( )
63+ } )
64+
65+ it ( 'using "registerProcessor" should not throw' , ( ) => {
66+ llmobs . registerProcessor ( ( ) => { } )
67+ } )
68+
69+ it ( 'using "deregisterProcessor" should not throw' , ( ) => {
70+ llmobs . deregisterProcessor ( )
71+ } )
72+
73+ it ( 'using "annotationContext" should not throw' , ( ) => {
74+ const result = llmobs . annotationContext ( { } , ( ) => {
75+ return 5
1976 } )
20- }
77+
78+ assert . equal ( result , 5 )
79+ } )
2180
2281 describe ( 'trace' , ( ) => {
2382 it ( 'should not throw with just a span' , ( ) => {
0 commit comments