This repository was archived by the owner on Sep 17, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +26
-31
lines changed
contrib/opencensus-ext-azure
opencensus/ext/azure/trace_exporter Expand file tree Collapse file tree 4 files changed +26
-31
lines changed Original file line number Diff line number Diff line change 66 ([ #930 ] ( https://github.com/census-instrumentation/opencensus-python/pull/930 ) )
77- Attach rate metrics for VM
88 ([ #935 ] ( https://github.com/census-instrumentation/opencensus-python/pull/935 ) )
9+ - Add links in properties for trace exporter envelopes
10+ ([ #936 ] ( https://github.com/census-instrumentation/opencensus-python/pull/936 ) )
911
1012## 1.0.4
1113Released 2020-06-29
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ import json
1516import logging
1617
1718from opencensus .common .schedule import QueueExitEvent
@@ -146,7 +147,13 @@ def span_data_to_envelope(self, sd):
146147 else :
147148 data .type = 'INPROC'
148149 data .success = True
149- # TODO: links, tracestate, tags
150+ if sd .links :
151+ links = []
152+ for link in sd .links :
153+ links .append (
154+ {"operation_Id" : link .trace_id , "id" : link .span_id })
155+ data .properties ["_MS.links" ] = json .dumps (links )
156+ # TODO: tracestate, tags
150157 for key in sd .attributes :
151158 # This removes redundant data from ApplicationInsights
152159 if key .startswith ('http.' ):
Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ import json
1516import os
1617import shutil
1718import unittest
1819
1920import mock
2021
2122from opencensus .ext .azure import trace_exporter
23+ from opencensus .trace .link import Link
2224
2325TEST_FOLDER = os .path .abspath ('.test.exporter' )
2426
@@ -141,7 +143,9 @@ def test_span_data_to_envelope(self):
141143 start_time = '2010-10-24T07:28:38.123456Z' ,
142144 end_time = '2010-10-24T07:28:38.234567Z' ,
143145 stack_trace = None ,
144- links = None ,
146+ links = [
147+ Link ('6e0c63257de34c90bf9efcd03927272e' , '6e0c63257de34c91' )
148+ ],
145149 status = Status (0 ),
146150 annotations = None ,
147151 message_events = None ,
@@ -188,6 +192,17 @@ def test_span_data_to_envelope(self):
188192 self .assertEqual (
189193 envelope .data .baseType ,
190194 'RemoteDependencyData' )
195+ json_dict = json .loads (
196+ envelope .data .baseData .properties ["_MS.links" ]
197+ )[0 ]
198+ self .assertEqual (
199+ json_dict ["id" ],
200+ "6e0c63257de34c91" ,
201+ )
202+ self .assertEqual (
203+ json_dict ["operation_Id" ],
204+ "6e0c63257de34c90bf9efcd03927272e" ,
205+ )
191206
192207 # SpanKind.CLIENT unknown type
193208 envelope = exporter .span_data_to_envelope (SpanData (
You can’t perform that action at this time.
0 commit comments