Skip to content

Feat/update #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3ce41e3
Create README.md
leocavalcante Jul 12, 2023
05afe00
feat: bring changes
leocavalcante Jul 13, 2023
2d7f1ae
fix(deps): Jaeger is a requirement
leocavalcante Jul 26, 2023
7bac2f6
fix: Typo
leocavalcante Jul 27, 2023
25fd60c
Don't require a tracer.root to enable a Span (#2)
leocavalcante Aug 17, 2023
abec708
chore(docs): Better readme
leocavalcante Sep 5, 2023
774a9f5
Refactor/uri sanitize fix patterns (#3)
vs0uz4 Sep 15, 2023
b28b031
Fix: TypeError & warnings (#4)
celosauro Sep 19, 2023
2bf095f
Upgrade deprecations (#5)
luizmanhani Dec 5, 2023
5f5b4de
Fix defer function (#6)
leocavalcante Dec 5, 2023
3d578e9
Change tracer span name (#7)
edurodriguesdias Jan 22, 2024
29e0957
fix: Sanitize URI regular expressions (OID & License Plate) (#9)
edurodriguesdias Mar 21, 2024
c1cca00
fix resource type warning (#12)
luizmanhani May 21, 2024
71c3ddd
ensuring that options tags will not send array that will break the sp…
luizmanhani Jun 6, 2024
8e34536
Revert "ensuring that options tags will not send array that will brea…
luizmanhani Jun 13, 2024
0e1297c
Otel Codec (#17)
luizmanhani Sep 16, 2024
3286019
creating a decoder to treat the traceId and spandId as jaeger client …
luizmanhani Sep 19, 2024
de74ee4
fix Guzzle psr7 invalid header error (#20)
luizmanhani Sep 24, 2024
5d014bc
Fix Thrift UDP Transport (#21)
lucas-angeli-gimenes Dec 30, 2024
c8ffef9
Allow custom traces enrichment (#23)
fkw3t Apr 4, 2025
607348c
merge from main lib;
luizmanhani Jul 24, 2025
2bcdf30
merge from main lib;
luizmanhani Jul 24, 2025
da39e49
bring recursive get root to TracerContext;
luizmanhani Jul 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.cache
.idea
.vscode
vendor/
99 changes: 99 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php

$header = <<<'EOF'
This file is part of Hyperf + OpenCodeCo

@link https://opencodeco.dev
@document https://hyperf.wiki
@contact [email protected]
@license https://github.com/opencodeco/hyperf-metric/blob/main/LICENSE
EOF;

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'@Symfony' => true,
'@DoctrineAnnotation' => true,
'@PhpCsFixer' => true,
'header_comment' => [
'comment_type' => 'PHPDoc',
'header' => $header,
'separate' => 'none',
'location' => 'after_declare_strict',
],
'array_syntax' => [
'syntax' => 'short'
],
'list_syntax' => [
'syntax' => 'short'
],
'concat_space' => [
'spacing' => 'one'
],
'blank_line_before_statement' => [
'statements' => [
'declare',
],
],
'general_phpdoc_annotation_remove' => [
'annotations' => [
'author'
],
],
'ordered_imports' => [
'imports_order' => [
'class', 'function', 'const',
],
'sort_algorithm' => 'alpha',
],
'single_line_comment_style' => [
'comment_types' => [
],
],
'yoda_style' => [
'always_move_variable' => false,
'equal' => false,
'identical' => false,
],
'phpdoc_align' => [
'align' => 'left',
],
'multiline_whitespace_before_semicolons' => [
'strategy' => 'no_multi_line',
],
'constant_case' => [
'case' => 'lower',
],
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
'class_attributes_separation' => true,
'combine_consecutive_unsets' => true,
'declare_strict_types' => true,
'linebreak_after_opening_tag' => true,
'lowercase_static_reference' => true,
'no_useless_else' => true,
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'not_operator_with_space' => false,
'ordered_class_elements' => true,
'php_unit_strict' => false,
'phpdoc_separation' => false,
'single_quote' => true,
'standardize_not_equals' => true,
'multiline_comment_opening_closing' => true,
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
])
->setFinder(
PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__)
)
->setUsingCache(true);
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) Hyperf
Copyright (c) Hyperf & OpenCodeCo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Hyperf Tracer

🔭 Drop-in replacement for the `hyperf/tracer` component.

Suited for special needs, especially for OpenTelemetry, New Relic and Dynatrace platforms.

## Getting started

### Install

#### Add OpenCodeCo's Composer repository:
```shell
composer config repositories.opencodeco composer https://composer.opencodeco.dev
```

#### Update your `hyperf/tracer`:
```shell
composer update hyperf/tracer
```
8 changes: 4 additions & 4 deletions class_map/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);
/**
* This file is part of Hyperf.
* This file is part of Hyperf + OpenCodeCo
*
* @link https://www.hyperf.io
* @link https://opencodeco.dev
* @document https://hyperf.wiki
* @contact [email protected]
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
* @contact [email protected]
* @license https://github.com/opencodeco/hyperf-metric/blob/main/LICENSE
*/

namespace Zipkin\Propagation;
Expand Down
98 changes: 98 additions & 0 deletions class_map/SpanContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php

declare(strict_types=1);
/**
* This file is part of Hyperf + OpenCodeCo
*
* @link https://opencodeco.dev
* @document https://hyperf.wiki
* @contact [email protected]
* @license https://github.com/opencodeco/hyperf-metric/blob/main/LICENSE
*/
namespace Jaeger;

use ArrayIterator;
use OpenTracing\SpanContext as OTSpanContext;
use ReturnTypeWillChange;

class SpanContext implements OTSpanContext
{
private array $baggage;

public function __construct(
private string $traceId,
private string $spanId,
private ?string $parentId = null,
private ?int $flags = null,
?array $baggage = null,
private ?int $debugId = null,
) {
$this->baggage = $baggage ?? [];
}

#[ReturnTypeWillChange]
public function getIterator(): ArrayIterator|iterable
{
return new ArrayIterator($this->baggage);
}

public function getBaggageItem(string $key): ?string
{
return $this->baggage[$key] ?? null;
}

/**
* @return SpanContext
*/
public function withBaggageItem(string $key, string $value): OTSpanContext
{
return new self(
$this->traceId,
$this->spanId,
$this->parentId,
$this->flags,
[$key => $value] + $this->baggage
);
}

public function getTraceId(): string
{
return $this->traceId;
}

public function setTraceId(string $traceId): self
{
$this->traceId = $traceId;
return $this;
}

public function getParentId(): ?string
{
return $this->parentId;
}

public function getSpanId(): string
{
return $this->spanId;
}

public function getFlags(): ?int
{
return $this->flags;
}

public function getBaggage(): array
{
return $this->baggage;
}

public function getDebugId(): ?int
{
return $this->debugId;
}

public function isDebugIdContainerOnly(): bool
{
return ($this->traceId === null) && ($this->debugId !== null);
}
}
Loading