ConsoleMetricExporter
in package
implements
PushMetricExporterInterface, AggregationTemporalitySelectorInterface
uses
LogsMessagesTrait
Writes metrics as human-readable JSON.
The output format is unspecified, is not OTLP and may change between releases. Use it for debugging and learning, not for parsing or as input to other tools.
Tags
Table of Contents
Interfaces
Properties
- $temporality : Temporality|string|AggregationTemporalitySelectorInterface|null
- $transport : TransportInterface
Methods
- __construct() : mixed
- export() : bool
- forceFlush() : bool
- shutdown() : bool
- temporality() : string|Temporality|null
- Returns the temporality to use for the given metric.
- logDebug() : void
- logError() : void
- logInfo() : void
- logNotice() : void
- logWarning() : void
- convertInstrumentationScope() : array<string|int, mixed>
- convertMetric() : array<string|int, mixed>
- convertResource() : array<string|int, mixed>
- doLog() : void
- Logging is best effort: a failing log writer (for example an error handler that throws on `trigger_error`) must not break the code that is being observed.
- normalize() : mixed
- JSON has no NaN or Infinity, so these use the protobuf JSON spellings.
- shouldLog() : bool
Properties
$temporality read-only
private
Temporality|string|AggregationTemporalitySelectorInterface|null
$temporality
= null
$transport read-only
private
TransportInterface
$transport
Methods
__construct()
public
__construct([Temporality|string|AggregationTemporalitySelectorInterface|null $temporality = null ][, TransportInterface|null $transport = null ]) : mixed
Parameters
- $temporality : Temporality|string|AggregationTemporalitySelectorInterface|null = null
-
a selector such as TemporalityPreference. Passing a Temporality or a string is deprecated. Null uses each stream's temporality until 2.0, and cumulative from 2.0.
- $transport : TransportInterface|null = null
export()
public
export(iterable<string|int, mixed> $batch) : bool
Parameters
- $batch : iterable<string|int, mixed>
Tags
Attributes
- #[Override]
Return values
boolforceFlush()
public
forceFlush() : bool
Attributes
- #[Override]
Return values
boolshutdown()
public
shutdown() : bool
Attributes
- #[Override]
Return values
booltemporality()
Returns the temporality to use for the given metric.
public
temporality(MetricMetadataInterface $metric) : string|Temporality|null
Parameters
- $metric : MetricMetadataInterface
Tags
Attributes
- #[Override]
Return values
string|Temporality|null —temporality to use, or null to signal that the given metric should not be exported by this exporter
logDebug()
protected
static logDebug(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logError()
protected
static logError(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logInfo()
protected
static logInfo(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logNotice()
protected
static logNotice(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
logWarning()
protected
static logWarning(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
- $message : string
- $context : array<string|int, mixed> = []
convertInstrumentationScope()
private
convertInstrumentationScope(InstrumentationScopeInterface $scope) : array<string|int, mixed>
Parameters
- $scope : InstrumentationScopeInterface
Return values
array<string|int, mixed>convertMetric()
private
convertMetric(Metric $metric) : array<string|int, mixed>
Parameters
- $metric : Metric
Return values
array<string|int, mixed>convertResource()
private
convertResource(ResourceInfo $resource) : array<string|int, mixed>
Parameters
- $resource : ResourceInfo
Return values
array<string|int, mixed>doLog()
Logging is best effort: a failing log writer (for example an error handler that throws on `trigger_error`) must not break the code that is being observed.
private
static doLog(string $level, string $message, array<string|int, mixed> $context) : void
Parameters
- $level : string
- $message : string
- $context : array<string|int, mixed>
normalize()
JSON has no NaN or Infinity, so these use the protobuf JSON spellings.
private
static normalize(mixed $value) : mixed
Parameters
- $value : mixed
shouldLog()
private
static shouldLog(string $level) : bool
Parameters
- $level : string