io.opentelemetry.sdk.metrics.internal.debug.SourceInfo Maven / Gradle / Ivy
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.sdk.metrics.internal.debug;
/**
* An interface that can be used to record the (runtime) source of registered metrics in the sdk.
*
* This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public interface SourceInfo {
/**
* Returns a debugging string to report where a given metric was registered.
*
*
Example: {@code MyFile.java:15}
*/
String shortDebugString();
/**
* Returns a multi-line debugging string to report where a given metric was registered.
*
*
Example:
*
*
* at full.package.name.method MyFile.java:15
* at full.packae.name.otherMethod MyOtherFile.java:10
*
*/
String multiLineDebugString();
/** Returns a source info that asks the user to register information. */
static SourceInfo noSourceInfo() {
return NoSourceInfo.INSTANCE;
}
/**
* Constructs source information form the current stack.
*
* This will attempt to ignore SDK classes.
*/
static SourceInfo fromCurrentStack() {
if (!DebugConfig.isMetricsDebugEnabled()) {
return noSourceInfo();
}
return new StackTraceSourceInfo(Thread.currentThread().getStackTrace());
}
}