-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: provide abstract telemetry classes (#1078)
- Loading branch information
Showing
37 changed files
with
547 additions
and
154 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"id": "0523c42d-d3a6-4789-800b-b613e6589170", | ||
"type": "feature", | ||
"description": "Provide new abstract versions of telemetry classes to simplify the creation of custom telemetry providers" | ||
} |
151 changes: 151 additions & 0 deletions
151
runtime/observability/telemetry-api/api/telemetry-api.api
Large diffs are not rendered by default.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
...telemetry-api/common/src/aws/smithy/kotlin/runtime/telemetry/AbstractTelemetryProvider.kt
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,30 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package aws.smithy.kotlin.runtime.telemetry | ||
|
||
import aws.smithy.kotlin.runtime.ExperimentalApi | ||
import aws.smithy.kotlin.runtime.telemetry.context.ContextManager | ||
import aws.smithy.kotlin.runtime.telemetry.logging.LoggerProvider | ||
import aws.smithy.kotlin.runtime.telemetry.metrics.MeterProvider | ||
import aws.smithy.kotlin.runtime.telemetry.trace.TracerProvider | ||
|
||
/** | ||
* An abstract implementation of a telemetry provider. By default, this class uses no-op implementations for all members | ||
* unless overridden in a subclass. | ||
*/ | ||
public abstract class AbstractTelemetryProvider : TelemetryProvider { | ||
@ExperimentalApi | ||
override val meterProvider: MeterProvider = MeterProvider.None | ||
|
||
@ExperimentalApi | ||
override val tracerProvider: TracerProvider = TracerProvider.None | ||
|
||
@ExperimentalApi | ||
override val loggerProvider: LoggerProvider = LoggerProvider.None | ||
|
||
@ExperimentalApi | ||
override val contextManager: ContextManager = ContextManager.None | ||
} |
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
13 changes: 13 additions & 0 deletions
13
...y/telemetry-api/common/src/aws/smithy/kotlin/runtime/telemetry/context/AbstractContext.kt
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,13 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package aws.smithy.kotlin.runtime.telemetry.context | ||
|
||
/** | ||
* An abstract implementation of telemetry provider context. By default, this class uses no-op implementations for all | ||
* members unless overridden in a subclass. | ||
*/ | ||
public abstract class AbstractContext : Context { | ||
override fun makeCurrent(): Scope = Scope.None | ||
} |
13 changes: 13 additions & 0 deletions
13
...etry-api/common/src/aws/smithy/kotlin/runtime/telemetry/context/AbstractContextManager.kt
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,13 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package aws.smithy.kotlin.runtime.telemetry.context | ||
|
||
/** | ||
* An abstract implementation of a context manager. By default, this class uses no-op implementations for all members | ||
* unless overridden in a subclass. | ||
*/ | ||
public abstract class AbstractContextManager : ContextManager { | ||
override fun current(): Context = Context.None | ||
} |
13 changes: 13 additions & 0 deletions
13
...ity/telemetry-api/common/src/aws/smithy/kotlin/runtime/telemetry/context/AbstractScope.kt
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,13 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package aws.smithy.kotlin.runtime.telemetry.context | ||
|
||
/** | ||
* An abstract implementation of a scope. By default, this class uses no-op implementations for all members unless | ||
* overridden in a subclass. | ||
*/ | ||
public abstract class AbstractScope : Scope { | ||
override fun close() { } | ||
} |
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
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
17 changes: 17 additions & 0 deletions
17
...ry-api/common/src/aws/smithy/kotlin/runtime/telemetry/logging/AbstractLogRecordBuilder.kt
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,17 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package aws.smithy.kotlin.runtime.telemetry.logging | ||
|
||
/** | ||
* An abstract implementation of a log record builder. By default, this class uses no-op implementations for all members | ||
* unless overridden in a subclass. | ||
*/ | ||
public abstract class AbstractLogRecordBuilder : LogRecordBuilder { | ||
override fun setCause(ex: Throwable) { } | ||
override fun setMessage(message: String) { } | ||
override fun setMessage(message: MessageSupplier) { } | ||
override fun setKeyValuePair(key: String, value: Any) { } | ||
override fun emit() { } | ||
} |
38 changes: 38 additions & 0 deletions
38
...ty/telemetry-api/common/src/aws/smithy/kotlin/runtime/telemetry/logging/AbstractLogger.kt
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,38 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package aws.smithy.kotlin.runtime.telemetry.logging | ||
|
||
/** | ||
* An abstract implementation of a logger. This class delegates the [trace], [debug], [info], [warn], and [error] | ||
* methods to a centralized [log] method which accepts [LogLevel] as a parameter. By default, this class uses no-op | ||
* implementations for all other members unless overridden in a subclass. | ||
*/ | ||
public abstract class AbstractLogger : Logger { | ||
override fun trace(t: Throwable?, msg: MessageSupplier) { | ||
if (isEnabledFor(LogLevel.Trace)) log(LogLevel.Trace, t, msg) | ||
} | ||
|
||
override fun debug(t: Throwable?, msg: MessageSupplier) { | ||
if (isEnabledFor(LogLevel.Debug)) log(LogLevel.Debug, t, msg) | ||
} | ||
|
||
override fun info(t: Throwable?, msg: MessageSupplier) { | ||
if (isEnabledFor(LogLevel.Info)) log(LogLevel.Info, t, msg) | ||
} | ||
|
||
override fun warn(t: Throwable?, msg: MessageSupplier) { | ||
if (isEnabledFor(LogLevel.Warning)) log(LogLevel.Warning, t, msg) | ||
} | ||
|
||
override fun error(t: Throwable?, msg: MessageSupplier) { | ||
if (isEnabledFor(LogLevel.Error)) log(LogLevel.Error, t, msg) | ||
} | ||
|
||
public open fun log(level: LogLevel, t: Throwable?, msg: MessageSupplier) { } | ||
|
||
override fun isEnabledFor(level: LogLevel): Boolean = false | ||
|
||
override fun atLevel(level: LogLevel): LogRecordBuilder = LogRecordBuilder.None | ||
} |
13 changes: 13 additions & 0 deletions
13
...etry-api/common/src/aws/smithy/kotlin/runtime/telemetry/logging/AbstractLoggerProvider.kt
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,13 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package aws.smithy.kotlin.runtime.telemetry.logging | ||
|
||
/** | ||
* An abstract implementation of a logger provider. By default, this class uses no-op implementations for all members | ||
* unless overridden in a subclass. | ||
*/ | ||
public abstract class AbstractLoggerProvider : LoggerProvider { | ||
override fun getOrCreateLogger(name: String): Logger = Logger.None | ||
} |
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
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
28 changes: 0 additions & 28 deletions
28
...bility/telemetry-api/common/src/aws/smithy/kotlin/runtime/telemetry/logging/NoOpLogger.kt
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
...ity/telemetry-api/common/src/aws/smithy/kotlin/runtime/telemetry/metrics/AbstractGauge.kt
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,13 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package aws.smithy.kotlin.runtime.telemetry.metrics | ||
|
||
/** | ||
* An abstract implementation of an asynchronous measurement handle. By default, this class uses no-op implementations | ||
* for all members unless overridden in a subclass. | ||
*/ | ||
public abstract class AbstractAsyncMeasurementHandle : AsyncMeasurementHandle { | ||
override fun stop() { } | ||
} |
19 changes: 19 additions & 0 deletions
19
...telemetry-api/common/src/aws/smithy/kotlin/runtime/telemetry/metrics/AbstractHistogram.kt
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,19 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package aws.smithy.kotlin.runtime.telemetry.metrics | ||
|
||
import aws.smithy.kotlin.runtime.collections.Attributes | ||
import aws.smithy.kotlin.runtime.telemetry.context.Context | ||
|
||
/** | ||
* An abstract implementation of a histogram. By default, this class uses no-op implementations for all members unless | ||
* overridden in a subclass. | ||
*/ | ||
public abstract class AbstractHistogram<T : Number> : Histogram<T> { | ||
override fun record(value: T, attributes: Attributes, context: Context?) { } | ||
} | ||
|
||
public typealias AbstractLongHistogram = AbstractHistogram<Long> | ||
public typealias AbstractDoubleHistogram = AbstractHistogram<Double> |
44 changes: 44 additions & 0 deletions
44
...ity/telemetry-api/common/src/aws/smithy/kotlin/runtime/telemetry/metrics/AbstractMeter.kt
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,44 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package aws.smithy.kotlin.runtime.telemetry.metrics | ||
|
||
/** | ||
* An abstract implementation of a meter. By default, this class uses no-op implementations for all members unless | ||
* overridden in a subclass. | ||
*/ | ||
public abstract class AbstractMeter : Meter { | ||
override fun createUpDownCounter(name: String, units: String?, description: String?): UpDownCounter = | ||
UpDownCounter.None | ||
|
||
override fun createAsyncUpDownCounter( | ||
name: String, | ||
callback: LongUpDownCounterCallback, | ||
units: String?, | ||
description: String?, | ||
): AsyncMeasurementHandle = AsyncMeasurementHandle.None | ||
|
||
override fun createMonotonicCounter(name: String, units: String?, description: String?): MonotonicCounter = | ||
MonotonicCounter.None | ||
|
||
override fun createLongHistogram(name: String, units: String?, description: String?): LongHistogram = | ||
Histogram.LongNone | ||
|
||
override fun createDoubleHistogram(name: String, units: String?, description: String?): DoubleHistogram = | ||
Histogram.DoubleNone | ||
|
||
override fun createLongGauge( | ||
name: String, | ||
callback: LongGaugeCallback, | ||
units: String?, | ||
description: String?, | ||
): AsyncMeasurementHandle = AsyncMeasurementHandle.None | ||
|
||
override fun createDoubleGauge( | ||
name: String, | ||
callback: DoubleGaugeCallback, | ||
units: String?, | ||
description: String?, | ||
): AsyncMeasurementHandle = AsyncMeasurementHandle.None | ||
} |
13 changes: 13 additions & 0 deletions
13
...metry-api/common/src/aws/smithy/kotlin/runtime/telemetry/metrics/AbstractMeterProvider.kt
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,13 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package aws.smithy.kotlin.runtime.telemetry.metrics | ||
|
||
/** | ||
* An abstract implementation of a meter provider. By default, this class uses no-op implementations for all members | ||
* unless overridden in a subclass. | ||
*/ | ||
public abstract class AbstractMeterProvider : MeterProvider { | ||
override fun getOrCreateMeter(scope: String): Meter = Meter.None | ||
} |
16 changes: 16 additions & 0 deletions
16
...ry-api/common/src/aws/smithy/kotlin/runtime/telemetry/metrics/AbstractMonotonicCounter.kt
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,16 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package aws.smithy.kotlin.runtime.telemetry.metrics | ||
|
||
import aws.smithy.kotlin.runtime.collections.Attributes | ||
import aws.smithy.kotlin.runtime.telemetry.context.Context | ||
|
||
/** | ||
* An abstract implementation of a monotonic counter. By default, this class uses no-op implementations for all members | ||
* unless overridden in a subclass. | ||
*/ | ||
public abstract class AbstractMonotonicCounter : MonotonicCounter { | ||
override fun add(value: Long, attributes: Attributes, context: Context?) { } | ||
} |
Oops, something went wrong.