@@ -74,6 +74,23 @@ function incrementLLMObsSpanFinishedCount (span, value = 1) {
7474 llmobsMetrics . count ( 'span.finished' , tags ) . inc ( value )
7575}
7676
77+ function recordLLMObsEnabled ( startTime , config , value = 1 ) {
78+ const initTimeMs = performance . now ( ) - startTime
79+ // There isn't an easy way to determine if a user automatically enabled LLMObs via
80+ // in-code or command line setup. We'll use the presence of DD_LLMOBS_ENABLED env var
81+ // as a rough heuristic, but note that this isn't perfect since
82+ // a user may have env vars but enable manually in code.
83+ const autoEnabled = ! ! config . _env ?. [ 'llmobs.enabled' ]
84+ const tags = {
85+ error : 0 ,
86+ agentless : Number ( config . llmobs . agentlessEnabled ) ,
87+ site : config . site ,
88+ auto : Number ( autoEnabled )
89+ }
90+ llmobsMetrics . count ( 'product_enabled' , tags ) . inc ( value )
91+ llmobsMetrics . distribution ( 'init_time' , tags ) . track ( initTimeMs )
92+ }
93+
7794function recordLLMObsRawSpanSize ( event , rawEventSize ) {
7895 const tags = extractTagsFromSpanEvent ( event )
7996 llmobsMetrics . distribution ( 'span.raw_size' , tags ) . track ( rawEventSize )
@@ -86,6 +103,7 @@ function recordLLMObsSpanSize (event, eventSize, shouldTruncate) {
86103}
87104
88105module . exports = {
106+ recordLLMObsEnabled,
89107 incrementLLMObsSpanStartCount,
90108 incrementLLMObsSpanFinishedCount,
91109 recordLLMObsRawSpanSize,
0 commit comments