11import static datadog .trace .api .config .GeneralConfig .AGENTLESS_LOG_SUBMISSION_ENABLED ;
22import static datadog .trace .api .config .GeneralConfig .AGENTLESS_LOG_SUBMISSION_LEVEL ;
3+ import static datadog .trace .api .config .GeneralConfig .ENV ;
4+ import static datadog .trace .api .config .GeneralConfig .SERVICE_NAME ;
5+ import static datadog .trace .api .config .GeneralConfig .VERSION ;
36import static datadog .trace .api .config .TraceInstrumentationConfig .LOGS_INJECTION_ENABLED ;
47import static datadog .trace .api .config .TraceInstrumentationConfig .TRACE_ENABLED ;
58import static java .util .Arrays .asList ;
6- import static java .util .Collections .emptyMap ;
79import static org .junit .jupiter .api .Assertions .assertEquals ;
810import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
911import static org .junit .jupiter .api .Assertions .assertNull ;
1820import datadog .trace .api .logging .intake .LogsWriter ;
1921import datadog .trace .bootstrap .instrumentation .api .AgentSpan ;
2022import datadog .trace .bootstrap .instrumentation .api .AgentTracer ;
23+ import datadog .trace .bootstrap .instrumentation .api .Tags ;
2124import datadog .trace .instrumentation .tinylog2 .ContextWriter ;
2225import datadog .trace .test .junit .utils .config .WithConfig ;
2326import java .util .HashMap ;
4750 key = "tinylog.writer2" ,
4851 value = "datadog.trace.instrumentation.tinylog2.ContextWriter" ,
4952 addPrefix = false )
53+ @ WithConfig (key = SERVICE_NAME , value = "tinylog-service" )
54+ @ WithConfig (key = ENV , value = "tinylog-env" )
55+ @ WithConfig (key = VERSION , value = "1.0" )
5056abstract class AbstractTinylogLogsIntakeForkedTest extends AbstractInstrumentationTest {
5157 static final List <Map <String , Object >> MESSAGES = new CopyOnWriteArrayList <>();
5258
@@ -80,6 +86,16 @@ static boolean injection() {
8086 return Config .get ().isLogsInjectionEnabled ();
8187 }
8288
89+ static Map <String , String > serviceTags () {
90+ Map <String , String > tags = new HashMap <>();
91+ if (injection ()) {
92+ tags .put (Tags .DD_SERVICE , "tinylog-service" );
93+ tags .put (Tags .DD_ENV , "tinylog-env" );
94+ tags .put (Tags .DD_VERSION , "1.0" );
95+ }
96+ return tags ;
97+ }
98+
8399 static boolean writingThread () {
84100 return Boolean .getBoolean ("tinylog.writingthread" );
85101 }
@@ -164,7 +180,7 @@ void submitsProducerContextAndPreservesUserContext() throws Exception {
164180 return ;
165181 }
166182 assertEquals (asList ("active" , "child" , "collision" , "outside" ), values ("message" ));
167- Map <String , String > expected = new HashMap <> ();
183+ Map <String , String > expected = serviceTags ();
168184 if (injection ()) {
169185 expected .put ("dd.trace_id" , traceId );
170186 expected .put ("dd.span_id" , spanId );
@@ -174,7 +190,7 @@ void submitsProducerContextAndPreservesUserContext() throws Exception {
174190 assertEquals (injection () ? traceId : null , contextMap (1 ).get ("dd.trace_id" ));
175191 assertEquals (injection () ? childSpanId : null , contextMap (1 ).get ("dd.span_id" ));
176192 assertEquals ("user-trace" , contextMap (2 ).get ("dd.trace_id" ));
177- assertEquals (emptyMap (), contextMap (3 ));
193+ assertEquals (serviceTags (), contextMap (3 ));
178194 }
179195
180196 static List <Object > values (String key ) {
0 commit comments