3939)
4040from langtrace_python_sdk .constants .exporter .langtrace_exporter import (
4141 LANGTRACE_REMOTE_URL ,
42+ LANGTRACE_SESSION_ID_HEADER ,
4243)
4344from langtrace_python_sdk .instrumentation import (
4445 AnthropicInstrumentation ,
@@ -135,15 +136,19 @@ def setup_tracer_provider(config: LangtraceConfig, host: str) -> TracerProvider:
135136
136137
137138def get_headers (config : LangtraceConfig ):
138- if not config .headers :
139- return {
140- "x-api-key" : config .api_key ,
141- }
139+ headers = {
140+ "x-api-key" : config .api_key ,
141+ }
142+
143+ if config .session_id :
144+ headers [LANGTRACE_SESSION_ID_HEADER ] = config .session_id
142145
143146 if isinstance (config .headers , str ):
144- return parse_env_headers (config .headers , liberal = True )
147+ headers .update (parse_env_headers (config .headers , liberal = True ))
148+ elif config .headers :
149+ headers .update (config .headers )
145150
146- return config . headers
151+ return headers
147152
148153
149154def get_exporter (config : LangtraceConfig , host : str ):
@@ -216,6 +221,7 @@ def init(
216221 service_name : Optional [str ] = None ,
217222 disable_logging : bool = False ,
218223 headers : Dict [str , str ] = {},
224+ session_id : Optional [str ] = None ,
219225):
220226
221227 check_if_sdk_is_outdated ()
@@ -230,6 +236,7 @@ def init(
230236 service_name = service_name ,
231237 disable_logging = disable_logging ,
232238 headers = headers ,
239+ session_id = session_id ,
233240 )
234241
235242 if config .disable_logging :
0 commit comments