Skip to content

Commit

Permalink
+ Configure method
Browse files Browse the repository at this point in the history
  • Loading branch information
EdmondDantes committed Oct 28, 2024
1 parent 94c6ecc commit 0b89315
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Added basic interfaces for the library and its implementation.
- Added Telemetry Exporters interfaces.
- Added basic `Tracer` class.
- `PSR-3` logger support.
- `BasicException` library support.

### Fixed


### Changed


24 changes: 24 additions & 0 deletions src/Tracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class Tracer implements TracerInterface
*/
protected bool $copyLogsToPsrLogger = false;

private bool $isConfigured = false;

/**
* Logs grouped by InstrumentationScopes.
*
Expand Down Expand Up @@ -84,6 +86,28 @@ public function __construct(
}
}

/**
* Configure the Tracer before use.
* This method can be called only once.
*/
public function configure(
?bool $populateLogsAsSpanEvents = null,
?bool $populateExceptionsToLog = null,
?bool $populateExceptionsToSpan = null,
?bool $copyLogsToPsrLogger = null
): void {
if ($this->isConfigured) {
return;
}

$this->isConfigured = true;

$this->populateLogsAsSpanEvents = $populateLogsAsSpanEvents ?? $this->populateLogsAsSpanEvents;
$this->populateExceptionsToLog = $populateExceptionsToLog ?? $this->populateExceptionsToLog;
$this->populateExceptionsToSpan = $populateExceptionsToSpan ?? $this->populateExceptionsToSpan;
$this->copyLogsToPsrLogger = $copyLogsToPsrLogger ?? $this->copyLogsToPsrLogger;
}

/**
* PSR-3 log adapter method.
* Translates PSR-3 log messages into OpenTelemetry log.
Expand Down

0 comments on commit 0b89315

Please sign in to comment.