public class Context extends Object
Resource
and
includes utility methods for constructing Metric
s that automatically
attach the Resource
to the Metric
.Constructor and Description |
---|
Context(io.opentelemetry.proto.resource.v1.Resource resource,
String domain) |
Context(io.opentelemetry.proto.resource.v1.Resource resource,
String domain,
boolean debugEnabled) |
Context(String domain) |
Modifier and Type | Method and Description |
---|---|
io.opentelemetry.proto.metrics.v1.MetricsData |
buildMetricsData(io.opentelemetry.proto.metrics.v1.Metric metric)
Build a
MetricsData containing a single Metric . |
io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest |
buildRequest(Iterable<io.opentelemetry.proto.metrics.v1.Metric> metrics) |
String |
getDomain() |
io.opentelemetry.proto.resource.v1.Resource |
getResource()
Get the
Resource in this Context. |
boolean |
isDebugEnabled() |
public Context(String domain)
public Context(io.opentelemetry.proto.resource.v1.Resource resource, String domain)
public Context(io.opentelemetry.proto.resource.v1.Resource resource, String domain, boolean debugEnabled)
public io.opentelemetry.proto.resource.v1.Resource getResource()
Resource
in this Context.
The Resource
represents the entity for which telemetry is being collected.
The buildMetricsData()
and buildRequest()
methods can be used to construct
OTLP messages with the Resource
and InstrumentationScope
from this context.
public boolean isDebugEnabled()
public String getDomain()
public io.opentelemetry.proto.metrics.v1.MetricsData buildMetricsData(io.opentelemetry.proto.metrics.v1.Metric metric)
MetricsData
containing a single Metric
.
If you have an ExportableMetric, prefer ExportableMetric.getMetricsData()
which memoizes the result.
public io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest buildRequest(Iterable<io.opentelemetry.proto.metrics.v1.Metric> metrics)