22
33-behaviour (otel_span_processor ).
44
5+ -include_lib (" opentelemetry/include/otel_span.hrl" ).
56-include_lib (" opentelemetry_api/include/opentelemetry.hrl" ).
67
78-export ([
1213-type processor_config () :: term ().
1314
1415-spec on_start (otel_ctx :t (), opentelemetry :span (), processor_config ()) -> opentelemetry :span ().
15- on_start (_Ctx , Span , _Config ) ->
16- Span .
16+ on_start (Ctx , Span , _Config ) ->
17+ Baggage = otel_baggage :get_all (Ctx ),
18+ Attributes = maps :map (fun (_K , {Value , _Metadata }) -> Value end , Baggage ),
19+ add_attributes (Span , Attributes ).
1720
1821-spec on_end (opentelemetry :span (), processor_config ()) ->
1922 true | dropped | {error , invalid_span } | {error , no_export_buffer }.
@@ -23,3 +26,7 @@ on_end(_Span, _Config) ->
2326-spec force_flush (processor_config ()) -> ok | {error , term ()}.
2427force_flush (_Config ) ->
2528 ok .
29+
30+ -spec add_attributes (opentelemetry :span (), opentelemetry :attributes_map ()) -> opentelemetry :span ().
31+ add_attributes (Span = # span {attributes = SpanAttributes }, AttributesMap ) ->
32+ Span # span {attributes = otel_attributes :set (AttributesMap , SpanAttributes )}.
0 commit comments