-
Notifications
You must be signed in to change notification settings - Fork 870
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jonas Kunz <[email protected]> Co-authored-by: Lauri Tulmin <[email protected]>
- Loading branch information
1 parent
2af49b4
commit 2100a16
Showing
5 changed files
with
114 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbScope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.influxdb.v2_4; | ||
|
||
import static io.opentelemetry.javaagent.instrumentation.influxdb.v2_4.InfluxDbSingletons.instrumenter; | ||
|
||
import io.opentelemetry.context.Context; | ||
import io.opentelemetry.context.Scope; | ||
|
||
/** Container used to carry state between enter and exit advices */ | ||
public final class InfluxDbScope { | ||
private final InfluxDbRequest influxDbRequest; | ||
private final Context context; | ||
private final Scope scope; | ||
|
||
private InfluxDbScope(InfluxDbRequest influxDbRequest, Context context, Scope scope) { | ||
this.influxDbRequest = influxDbRequest; | ||
this.context = context; | ||
this.scope = scope; | ||
} | ||
|
||
public static InfluxDbScope start(Context parentContext, InfluxDbRequest influxDbRequest) { | ||
Context context = instrumenter().start(parentContext, influxDbRequest); | ||
return new InfluxDbScope(influxDbRequest, context, context.makeCurrent()); | ||
} | ||
|
||
public void end(Throwable throwable) { | ||
if (scope == null) { | ||
return; | ||
} | ||
|
||
scope.close(); | ||
|
||
instrumenter().end(context, influxDbRequest, null, throwable); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters