Skip to content

Commit 5c6584c

Browse files
authored
OTel Benchmarker, Fixes AB#3404902 (#2786)
[AB#3404902](https://identitydivision.visualstudio.com/fac9d424-53d2-45c0-91b5-ef6ba7a6bf26/_workitems/edit/3404902) Add a benchmarker that can be hooked up with OTelUtility. This is disabled by default. To Enable it, set this when the process (e.g. broker) is initiated. <img width="941" height="159" alt="image" src="https://github.com/user-attachments/assets/3828e19c-9f32-4721-b1e2-217d1b0bcdaf" /> This benchmarker will record the timestamp every time an attribute/event is set in the given span(s). It would calculate (average, by percentile) and print a summary to a file that would look like this. ``` === Statistical Benchmark Session: 2025-10-15 15:02:42.608 | Avg Total Duration: 663ms | Avg Concurrent Size: 3.32 | Batch Size: 1000 === | Status Entry | Metric | Time Since Previous | Time Since Start | |--------------------------------------------------|--------|---------------------|------------------| | timestamp_request_hitting_broker | Avg | 0ms | 0ms | | | P50 | 0ms | 0ms | | | P95 | 0ms | 0ms | |--------------------------------------------------|--------|---------------------|------------------| | timestamp_ats_starts | Avg | 0ms | 0ms | | | P50 | 0ms | 0ms | | | P95 | 0ms | 0ms | |--------------------------------------------------|--------|---------------------|------------------| | calling_package_name | Avg | 0ms | 0ms | | | P50 | 0ms | 0ms | | | P95 | 0ms | 0ms | |--------------------------------------------------|--------|---------------------|------------------| | device_idle_mode | Avg | 0ms | 0ms | | | P50 | 0ms | 0ms | | | P95 | 1ms | 1ms | |--------------------------------------------------|--------|---------------------|------------------| | power_optimization_settings | Avg | 0ms | 0ms | | | P50 | 0ms | 0ms | | | P95 | 0ms | 1ms | |--------------------------------------------------|--------|---------------------|------------------| | account_home_account_id_supplied_to_broker_reque | Avg | 0ms | 1ms | | | P50 | 1ms | 1ms | | | P95 | 2ms | 4ms | |--------------------------------------------------|--------|---------------------|------------------| | account_local_account_id_supplied_to_broker_requ | Avg | 0ms | 1ms | | | P50 | 0ms | 1ms | | | P95 | 0ms | 4ms | |--------------------------------------------------|--------|---------------------|------------------| | elapsed_time_cache_get_account_by_local_account_ | Avg | 19ms | 21ms | | | P50 | 19ms | 20ms | | | P95 | 28ms | 31ms | |--------------------------------------------------|--------|---------------------|------------------| | target_cloud | Avg | 0ms | 21ms | | | P50 | 0ms | 21ms | | | P95 | 0ms | 31ms | |--------------------------------------------------|--------|---------------------|------------------| | target_audience | Avg | 0ms | 21ms | | | P50 | 0ms | 21ms | | | P95 | 0ms | 31ms | |--------------------------------------------------|--------|---------------------|------------------| | is_using_strong_key_with_tb_ca | Avg | 31ms | 54ms | | | P50 | 28ms | 50ms | | | P95 | 61ms | 85ms | |--------------------------------------------------|--------|---------------------|------------------| | is_msa_passthrough_request | Avg | 16ms | 71ms | | | P50 | 16ms | 68ms | | | P95 | 32ms | 115ms | |--------------------------------------------------|--------|---------------------|------------------| | elapsed_time_load_prt | Avg | 21ms | 127ms | | | P50 | 19ms | 120ms | | | P95 | 42ms | 204ms | |--------------------------------------------------|--------|---------------------|------------------| | num_concurrent_silent_requests | Avg | 1ms | 129ms | | | P50 | 1ms | 122ms | | | P95 | 2ms | 206ms | |--------------------------------------------------|--------|---------------------|------------------| | timestamp_ats_executed_by_dispatcher | Avg | 0ms | 129ms | | | P50 | 0ms | 122ms | | | P95 | 0ms | 206ms | |--------------------------------------------------|--------|---------------------|------------------| | application_name | Avg | 0ms | 129ms | | | P50 | 0ms | 122ms | | | P95 | 0ms | 206ms | |--------------------------------------------------|--------|---------------------|------------------| | public_api_id | Avg | 0ms | 129ms | | | P50 | 0ms | 122ms | | | P95 | 0ms | 206ms | |--------------------------------------------------|--------|---------------------|------------------| | controller_name | Avg | 0ms | 129ms | | | P50 | 0ms | 122ms | | | P95 | 0ms | 206ms | |--------------------------------------------------|--------|---------------------|------------------| | required_broker_protocol_version | Avg | 0ms | 130ms | | | P50 | 1ms | 124ms | | | P95 | 2ms | 207ms | |--------------------------------------------------|--------|---------------------|------------------| | client_sku | Avg | 0ms | 131ms | | | P50 | 0ms | 124ms | | | P95 | 0ms | 207ms | |--------------------------------------------------|--------|---------------------|------------------| | sku_version | Avg | 0ms | 131ms | | | P50 | 0ms | 124ms | | | P95 | 0ms | 207ms | |--------------------------------------------------|--------|---------------------|------------------| | correlation_id | Avg | 0ms | 131ms | | | P50 | 0ms | 124ms | | | P95 | 0ms | 207ms | |--------------------------------------------------|--------|---------------------|------------------| | force_refresh | Avg | 0ms | 131ms | | | P50 | 0ms | 124ms | | | P95 | 0ms | 207ms | |--------------------------------------------------|--------|---------------------|------------------| | auth_scheme_name | Avg | 0ms | 131ms | | | P50 | 0ms | 124ms | | | P95 | 0ms | 207ms | |--------------------------------------------------|--------|---------------------|------------------| | claims_request_json | Avg | 0ms | 131ms | | | P50 | 0ms | 124ms | | | P95 | 0ms | 207ms | |--------------------------------------------------|--------|---------------------|------------------| | tenant_id | Avg | 1ms | 132ms | | | P50 | 1ms | 125ms | | | P95 | 4ms | 209ms | |--------------------------------------------------|--------|---------------------|------------------| | account_type | Avg | 1ms | 134ms | | | P50 | 1ms | 127ms | | | P95 | 3ms | 214ms | |--------------------------------------------------|--------|---------------------|------------------| | calling_package_version | Avg | 0ms | 134ms | | | P50 | 0ms | 127ms | | | P95 | 0ms | 214ms | |--------------------------------------------------|--------|---------------------|------------------| | broker_version | Avg | 0ms | 134ms | | | P50 | 0ms | 127ms | | | P95 | 0ms | 214ms | |--------------------------------------------------|--------|---------------------|------------------| | negotiated_broker_protocol_version | Avg | 0ms | 134ms | | | P50 | 0ms | 127ms | | | P95 | 0ms | 214ms | |--------------------------------------------------|--------|---------------------|------------------| | is_nested_app_request | Avg | 0ms | 134ms | | | P50 | 0ms | 127ms | | | P95 | 0ms | 214ms | |--------------------------------------------------|--------|---------------------|------------------| | is_instance_aware | Avg | 0ms | 134ms | | | P50 | 0ms | 127ms | | | P95 | 0ms | 214ms | |--------------------------------------------------|--------|---------------------|------------------| | environment | Avg | 0ms | 134ms | | | P50 | 0ms | 127ms | | | P95 | 0ms | 214ms | |--------------------------------------------------|--------|---------------------|------------------| | session_key_loader_type | Avg | 0ms | 134ms | | | P50 | 0ms | 127ms | | | P95 | 0ms | 214ms | |--------------------------------------------------|--------|---------------------|------------------| | is_shared_device | Avg | 0ms | 134ms | | | P50 | 0ms | 127ms | | | P95 | 0ms | 214ms | |--------------------------------------------------|--------|---------------------|------------------| | is_joined_flow | Avg | 0ms | 134ms | | | P50 | 0ms | 127ms | | | P95 | 0ms | 214ms | |--------------------------------------------------|--------|---------------------|------------------| | reg_source | Avg | 0ms | 134ms | | | P50 | 0ms | 127ms | | | P95 | 0ms | 214ms | |--------------------------------------------------|--------|---------------------|------------------| | reg_type | Avg | 0ms | 134ms | | | P50 | 0ms | 127ms | | | P95 | 0ms | 214ms | |--------------------------------------------------|--------|---------------------|------------------| | lock_acquisition_time_acquire_registered_device_ | Avg | 0ms | 140ms | | | P50 | 0ms | 133ms | | | P95 | 0ms | 221ms | |--------------------------------------------------|--------|---------------------|------------------| | is_registered_device_prt | Avg | 0ms | 147ms | | | P50 | 0ms | 140ms | | | P95 | 0ms | 231ms | |--------------------------------------------------|--------|---------------------|------------------| | elapsed_time_registered_device_prt | Avg | 0ms | 147ms | | | P50 | 0ms | 140ms | | | P95 | 0ms | 231ms | |--------------------------------------------------|--------|---------------------|------------------| | lock_acquisition_time_acquire_at_outer_lock | Avg | 0ms | 147ms | | | P50 | 0ms | 140ms | | | P95 | 0ms | 231ms | |--------------------------------------------------|--------|---------------------|------------------| | lock_acquisition_time_acquire_at_inner_lock | Avg | 0ms | 147ms | | | P50 | 0ms | 140ms | | | P95 | 0ms | 231ms | |--------------------------------------------------|--------|---------------------|------------------| | prt_protocol_version | Avg | 15ms | 233ms | | | P50 | 14ms | 229ms | | | P95 | 30ms | 350ms | |--------------------------------------------------|--------|---------------------|------------------| | acquire_token_silent_with_nonce | Avg | 0ms | 234ms | | | P50 | 1ms | 230ms | | | P95 | 1ms | 351ms | |--------------------------------------------------|--------|---------------------|------------------| | kdf_version | Avg | 0ms | 234ms | | | P50 | 0ms | 230ms | | | P95 | 0ms | 351ms | |--------------------------------------------------|--------|---------------------|------------------| | derived_key_jwt_signing_performance | Avg | 1ms | 236ms | | | P50 | 1ms | 233ms | | | P95 | 2ms | 354ms | |--------------------------------------------------|--------|---------------------|------------------| | elapsed_time_jwt_signing_session_key | Avg | 0ms | 236ms | | | P50 | 0ms | 233ms | | | P95 | 0ms | 354ms | |--------------------------------------------------|--------|---------------------|------------------| | elapsed_time_create_token_request_internal | Avg | 0ms | 237ms | | | P50 | 0ms | 233ms | | | P95 | 0ms | 354ms | |--------------------------------------------------|--------|---------------------|------------------| | elapsed_time_create_token_request | Avg | 0ms | 237ms | | | P50 | 0ms | 233ms | | | P95 | 0ms | 354ms | |--------------------------------------------------|--------|---------------------|------------------| | response_content_type | Avg | 310ms | 548ms | | | P50 | 297ms | 535ms | | | P95 | 398ms | 698ms | |--------------------------------------------------|--------|---------------------|------------------| | ccs_request_id | Avg | 0ms | 548ms | | | P50 | 0ms | 535ms | | | P95 | 0ms | 698ms | |--------------------------------------------------|--------|---------------------|------------------| | ccs_request_sequence | Avg | 0ms | 548ms | | | P50 | 0ms | 535ms | | | P95 | 0ms | 698ms | |--------------------------------------------------|--------|---------------------|------------------| | response_body_length | Avg | 0ms | 548ms | | | P50 | 0ms | 535ms | | | P95 | 0ms | 698ms | |--------------------------------------------------|--------|---------------------|------------------| | http_status_code | Avg | 0ms | 548ms | | | P50 | 0ms | 535ms | | | P95 | 0ms | 698ms | |--------------------------------------------------|--------|---------------------|------------------| | elapsed_time_network_acquire_at | Avg | 0ms | 548ms | | | P50 | 0ms | 535ms | | | P95 | 0ms | 698ms | |--------------------------------------------------|--------|---------------------|------------------| | jwt_valid | Avg | 1ms | 550ms | | | P50 | 2ms | 538ms | | | P95 | 4ms | 700ms | |--------------------------------------------------|--------|---------------------|------------------| | jwt_alg | Avg | 0ms | 550ms | | | P50 | 0ms | 538ms | | | P95 | 0ms | 700ms | |--------------------------------------------------|--------|---------------------|------------------| | iv_decoded_length | Avg | 0ms | 550ms | | | P50 | 0ms | 538ms | | | P95 | 0ms | 700ms | |--------------------------------------------------|--------|---------------------|------------------| | payload_ciphertext_length | Avg | 0ms | 550ms | | | P50 | 0ms | 538ms | | | P95 | 0ms | 700ms | |--------------------------------------------------|--------|---------------------|------------------| | derived_key_ctx_length | Avg | 0ms | 550ms | | | P50 | 0ms | 538ms | | | P95 | 0ms | 700ms | |--------------------------------------------------|--------|---------------------|------------------| | authentication_tag_length | Avg | 0ms | 550ms | | | P50 | 0ms | 538ms | | | P95 | 0ms | 700ms | |--------------------------------------------------|--------|---------------------|------------------| | derived_key_aesgcm_decryption_performance | Avg | 1ms | 552ms | | | P50 | 1ms | 539ms | | | P95 | 2ms | 702ms | |--------------------------------------------------|--------|---------------------|------------------| | elapsed_time_decrypt_jwe | Avg | 0ms | 552ms | | | P50 | 0ms | 539ms | | | P95 | 0ms | 702ms | |--------------------------------------------------|--------|---------------------|------------------| | elapsed_time_network_acquire_prt | Avg | 0ms | 554ms | | | P50 | 0ms | 541ms | | | P95 | 0ms | 705ms | |--------------------------------------------------|--------|---------------------|------------------| | elapsed_time_save_token_result | Avg | 102ms | 656ms | | | P50 | 90ms | 643ms | | | P95 | 173ms | 830ms | |--------------------------------------------------|--------|---------------------|------------------| | is_serviced_from_cache | Avg | 0ms | 656ms | | | P50 | 0ms | 643ms | | | P95 | 0ms | 830ms | |--------------------------------------------------|--------|---------------------|------------------| | SetStatus:OK | Avg | 0ms | 656ms | | | P50 | 0ms | 643ms | | | P95 | 0ms | 830ms | |--------------------------------------------------|--------|---------------------|------------------| | timestamp_ats_finished | Avg | 0ms | 656ms | | | P50 | 0ms | 643ms | | | P95 | 0ms | 830ms | |--------------------------------------------------|--------|---------------------|------------------| | stop_returning_rt_result | Avg | 0ms | 657ms | | | P50 | 0ms | 643ms | | | P95 | 1ms | 831ms | |--------------------------------------------------|--------|---------------------|------------------| ```
1 parent dc33950 commit 5c6584c

File tree

12 files changed

+1053
-143
lines changed

12 files changed

+1053
-143
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
vNext
22
----------
3+
- [MINOR] Add OTel Benchmarker (#2786)
34
- [MAJOR] Add KeyStoreBackedSecretKeyProvider (#2674)
45
- [MINOR] Add Open Id configuration issuer validation reporting in OpenIdProviderConfigurationClient (#2751)
56
- [MINOR] Add helper method to record elapsed time (#2768)

common4j/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def nativeAuthConfigFilePathParameter = "" // will be blank unless specified by
166166
def nativeAuthConfigStringParameter = "" // will be blank unless specified by developer, used to run e2e tests in CI
167167
def disableAcquireTokenSilentTimeoutParameter = false // will be false unless specified by developer
168168
def allowOneboxAuthorities = false // will be false unless specified by developer
169+
def shouldSkipSilentTokenCommandCacheForStressTest = false // will be false unless specified by developer, required for running concurrent stress test in MSAL/Broker.
169170

170171
if (project.hasProperty("slice")) {
171172
sliceParameter = slice
@@ -205,6 +206,10 @@ if (project.hasProperty("allowOneboxAuthorities")) {
205206
allowOneboxAuthorities = true
206207
}
207208

209+
if (project.hasProperty("shouldSkipSilentTokenCommandCacheForStressTest")) {
210+
shouldSkipSilentTokenCommandCacheForStressTest = true
211+
}
212+
208213
sourceSets {
209214
main {
210215
java.srcDirs = ['src/main', "$project.buildDir/generated/source/buildConfig/main"]
@@ -216,6 +221,7 @@ sourceSets {
216221
buildConfigField("String", "NATIVE_AUTH_CONFIG_STRING", "\"$nativeAuthConfigStringParameter\"")
217222
buildConfigField("boolean", "DISABLE_ACQUIRE_TOKEN_SILENT_TIMEOUT", "${disableAcquireTokenSilentTimeoutParameter}")
218223
buildConfigField("boolean", "ALLOW_ONEBOX_AUTHORITIES", "${allowOneboxAuthorities}")
224+
buildConfigField("boolean", "SHOULD_SKIP_SILENT_TOKEN_COMMAND_CACHE_FOR_STRESS_TEST", "${shouldSkipSilentTokenCommandCacheForStressTest}")
219225
}
220226
test {
221227
java.srcDirs = ['src/test']

common4j/src/main/com/microsoft/identity/common/java/commands/SilentTokenCommand.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// THE SOFTWARE.
2323
package com.microsoft.identity.common.java.commands;
2424

25+
import com.microsoft.identity.common.java.BuildConfig;
2526
import com.microsoft.identity.common.java.WarningType;
2627
import com.microsoft.identity.common.java.commands.parameters.SilentTokenCommandParameters;
2728
import com.microsoft.identity.common.java.constants.OAuth2ErrorCode;
@@ -150,6 +151,11 @@ public AcquireTokenResult execute() throws Exception {
150151

151152
@Override
152153
public boolean isEligibleForCaching() {
154+
if (BuildConfig.SHOULD_SKIP_SILENT_TOKEN_COMMAND_CACHE_FOR_STRESS_TEST) {
155+
// by disabling this, MSAL/Broker will allow similar request to be executed
156+
// as opposed to being handled by cache.
157+
return false;
158+
}
153159
return true;
154160
}
155161

common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
import java.util.concurrent.ExecutionException;
9090
import java.util.concurrent.ExecutorService;
9191
import java.util.concurrent.Executors;
92+
import java.util.concurrent.ThreadPoolExecutor;
9293
import java.util.concurrent.TimeUnit;
9394
import java.util.concurrent.TimeoutException;
9495

@@ -114,6 +115,14 @@ public class CommandDispatcher {
114115
@SuppressWarnings(WarningType.rawtype_warning)
115116
private static ConcurrentMap<BaseCommand, FinalizableResultFuture<CommandResult>> sExecutingCommandMap = new ConcurrentHashMap<>();
116117

118+
/**
119+
* Returns the approximate number of threads that are actively
120+
* executing tasks in the silent request thread pool.
121+
*/
122+
public static int getSilentRequestActiveCount(){
123+
return ((ThreadPoolExecutor)sSilentExecutor).getActiveCount();
124+
}
125+
117126
/**
118127
* Remove all keys that are the command reference from the executing command map. Since if they key has
119128
* been changed, remove will not work, construct a new map and add all keys that are not identically
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// All rights reserved.
3+
//
4+
// This code is licensed under the MIT License.
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files(the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions :
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
23+
package com.microsoft.identity.common.java.opentelemetry
24+
25+
import com.microsoft.identity.common.java.controllers.CommandDispatcher
26+
import io.opentelemetry.api.common.AttributeKey
27+
import io.opentelemetry.api.common.Attributes
28+
import io.opentelemetry.api.trace.Span
29+
import io.opentelemetry.api.trace.SpanContext
30+
import io.opentelemetry.api.trace.StatusCode
31+
import java.util.concurrent.TimeUnit
32+
33+
interface IBenchmarkSpan {
34+
/**
35+
* Returns a list of status changes along with their timestamps in nanoseconds.
36+
**/
37+
fun getStatuses(): List<Pair<String, Long>>
38+
39+
/**
40+
* Returns the span name.
41+
**/
42+
fun getSpanName(): String
43+
44+
/**
45+
* The start time of the span in nanoseconds.
46+
**/
47+
fun getStartTimeInNanoSeconds(): Long
48+
49+
/**
50+
* The end time of the span in nanoseconds.
51+
**/
52+
fun getEndTimeInNanoSeconds(): Long
53+
54+
/**
55+
* # of concurrent active silent requests when this span is started.
56+
**/
57+
fun getConcurrentSilentRequestSize(): Int
58+
59+
/**
60+
* The exception recorded on this span, if any.
61+
**/
62+
fun getException(): Throwable?
63+
}
64+
65+
/**
66+
* A span wrapper class for benchmarking purposes.
67+
*
68+
* @param originalSpan The original span to be wrapped.
69+
* @param printer The printer to print the benchmark results.
70+
* @param spanName The name of the span.
71+
**/
72+
class BenchmarkSpan(
73+
val originalSpan: Span,
74+
val printer: IBenchmarkSpanPrinter,
75+
private val spanName: String) : Span, IBenchmarkSpan {
76+
77+
// Pair of (status name, timestamp in nano seconds)
78+
val statuses : ArrayList<Pair<String, Long>> = arrayListOf()
79+
private var exception: Throwable? = null
80+
81+
private var startTimeInNanoSeconds: Long = System.nanoTime()
82+
private var endTimeInNanoSeconds: Long = 0L
83+
84+
// # of concurrent active silent requests when this span is started.
85+
private var concurrentSize = 1
86+
87+
override fun getStatuses(): List<Pair<String, Long>> {
88+
return statuses
89+
}
90+
91+
override fun getSpanName(): String {
92+
return spanName
93+
}
94+
95+
override fun getStartTimeInNanoSeconds(): Long {
96+
return startTimeInNanoSeconds
97+
}
98+
99+
override fun getEndTimeInNanoSeconds(): Long {
100+
return endTimeInNanoSeconds
101+
}
102+
103+
override fun getConcurrentSilentRequestSize(): Int {
104+
return concurrentSize
105+
}
106+
107+
override fun getException(): Throwable? {
108+
return exception
109+
}
110+
111+
fun start(){
112+
startTimeInNanoSeconds = System.nanoTime()
113+
concurrentSize = CommandDispatcher.getSilentRequestActiveCount()
114+
}
115+
116+
override fun end() {
117+
endTimeInNanoSeconds = System.nanoTime()
118+
printer.printAsync(this)
119+
return originalSpan.end()
120+
}
121+
122+
override fun end(timestamp: Long, unit: TimeUnit) {
123+
endTimeInNanoSeconds = System.nanoTime()
124+
printer.printAsync(this)
125+
return originalSpan.end(timestamp, unit)
126+
}
127+
128+
override fun <T : Any?> setAttribute(
129+
key: AttributeKey<T>,
130+
value: T
131+
): Span? {
132+
statuses.add(Pair(key.toString(), System.nanoTime()))
133+
return originalSpan.setAttribute(key, value)
134+
}
135+
136+
override fun addEvent(
137+
name: String,
138+
attributes: Attributes
139+
): Span? {
140+
statuses.add(Pair(name, System.nanoTime()))
141+
return originalSpan.addEvent(name, attributes)
142+
}
143+
144+
override fun addEvent(
145+
name: String,
146+
attributes: Attributes,
147+
timestamp: Long,
148+
unit: TimeUnit
149+
): Span? {
150+
statuses.add(Pair(name, System.nanoTime()))
151+
return originalSpan.addEvent(name, attributes, timestamp, unit)
152+
}
153+
154+
override fun setStatus(
155+
statusCode: StatusCode,
156+
description: String
157+
): Span? {
158+
statuses.add(Pair("SetStatus:$statusCode", System.nanoTime()))
159+
return originalSpan.setStatus(statusCode, description)
160+
}
161+
162+
override fun recordException(
163+
exception: Throwable,
164+
additionalAttributes: Attributes
165+
): Span? {
166+
val timestamp = System.nanoTime()
167+
statuses.add(Pair("recordException", timestamp))
168+
this.exception = exception
169+
return originalSpan.recordException(exception, additionalAttributes)
170+
}
171+
172+
override fun updateName(name: String): Span? {
173+
return originalSpan.updateName(name)
174+
}
175+
176+
override fun getSpanContext(): SpanContext? {
177+
return originalSpan.spanContext
178+
}
179+
180+
override fun isRecording(): Boolean {
181+
return originalSpan.isRecording
182+
}
183+
}

0 commit comments

Comments
 (0)