Skip to content

Commit

Permalink
Rename XCloudTrace to CloudTrace
Browse files Browse the repository at this point in the history
  • Loading branch information
ynikitin-etsy committed Nov 15, 2023
1 parent d6c4c89 commit 779a1b8
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .gitsplit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ splits:
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/exporter-zipkin.git"
- prefix: "src/Extension/Propagator/B3"
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/extension-propagator-b3.git"
- prefix: "src/Extension/Propagator/XCloudTrace"
- prefix: "src/Extension/Propagator/CloudTrace"
target: "https://${GH_TOKEN}@github.com/opentelemetry-php/extension-propagator-cloudtrace.git"

# List of references to split (defined as regexp)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"src/Contrib/Grpc/_register.php",
"src/Contrib/Zipkin/_register.php",
"src/Extension/Propagator/B3/_register.php",
"src/Extension/Propagator/XCloudTrace/_register.php",
"src/Extension/Propagator/CloudTrace/_register.php",
"src/SDK/Logs/Exporter/_register.php",
"src/SDK/Metrics/MetricExporter/_register.php",
"src/SDK/Propagation/_register.php",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace OpenTelemetry\Extension\Propagator\XCloudTrace;
namespace OpenTelemetry\Extension\Propagator\CloudTrace;

use OpenTelemetry\API\Trace\SpanContext;
use OpenTelemetry\API\Trace\SpanContextInterface;
Expand All @@ -14,7 +14,7 @@
* least significant bit which signals whether the request was traced or not
* (1 = traced, 0 = not traced).
*/
final class XCloudTraceFormatter
final class CloudTraceFormatter
{
const CONTEXT_HEADER_FORMAT = '/([0-9a-fA-F]{32})(?:\/(\d+))?(?:;o=(\d+))?/';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace OpenTelemetry\Extension\Propagator\XCloudTrace;
namespace OpenTelemetry\Extension\Propagator\CloudTrace;

use OpenTelemetry\API\Trace\Span;
use OpenTelemetry\Context\Context;
Expand All @@ -13,19 +13,19 @@
use OpenTelemetry\Context\Propagation\TextMapPropagatorInterface;

/**
* XCloudTracePropagator is a propagator that supports the specification for the X-Cloud-Trace-Context
* CloudTracePropagator is a propagator that supports the specification for the X-Cloud-Trace-Context
* header used for trace context propagation across service boundaries.
* (https://cloud.google.com/trace/docs/setup#force-trace)
*/
final class XCloudTracePropagator implements TextMapPropagatorInterface
final class CloudTracePropagator implements TextMapPropagatorInterface
{
private static ?TextMapPropagatorInterface $oneWayInstance = null;
private static ?TextMapPropagatorInterface $instance = null;

public static function getOneWayInstance(): TextMapPropagatorInterface
{
if (self::$oneWayInstance === null) {
self::$oneWayInstance = new XCloudTracePropagator(true);
self::$oneWayInstance = new CloudTracePropagator(true);
}

return self::$oneWayInstance;
Expand All @@ -34,7 +34,7 @@ public static function getOneWayInstance(): TextMapPropagatorInterface
public static function getInstance(): TextMapPropagatorInterface
{
if (self::$instance === null) {
self::$instance = new XCloudTracePropagator(false);
self::$instance = new CloudTracePropagator(false);
}

return self::$instance;
Expand Down Expand Up @@ -74,7 +74,7 @@ public function inject(&$carrier, PropagationSetterInterface $setter = null, Con
return;
}

$headerValue = XCloudTraceFormatter::serialize($spanContext);
$headerValue = CloudTraceFormatter::serialize($spanContext);
$setter->set($carrier, self::XCLOUD, $headerValue);
}

Expand All @@ -89,7 +89,7 @@ public function extract($carrier, PropagationGetterInterface $getter = null, Con
return $context;
}

$spanContext = XCloudTraceFormatter::deserialize($headerValue);
$spanContext = CloudTraceFormatter::deserialize($headerValue);
if (!$spanContext->isValid()) {
return $context;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
[![Releases](https://img.shields.io/badge/releases-purple)](https://github.com/opentelemetry-php/extension-propagator-cloudtrace/releases)
[![Source](https://img.shields.io/badge/source-extension--propagator--xcloudtrace-green)](https://github.com/open-telemetry/opentelemetry-php/tree/main/src/Extension/Propagator/XCloudTrace)
[![Mirror](https://img.shields.io/badge/mirror-opentelemetry--php:extension--propagator--xcloudtrace-blue)](https://github.com/opentelemetry-php/extension-propagator-cloudtrace)
[![Source](https://img.shields.io/badge/source-extension--propagator--cloudtrace-green)](https://github.com/open-telemetry/opentelemetry-php/tree/main/src/Extension/Propagator/CloudTrace)
[![Mirror](https://img.shields.io/badge/mirror-opentelemetry--php:extension--propagator--cloudtrace-blue)](https://github.com/opentelemetry-php/extension-propagator-cloudtrace)
[![Latest Version](http://poser.pugx.org/open-telemetry/extension-propagator-cloudtrace/v/unstable)](https://packagist.org/packages/open-telemetry/extension-propagator-cloudtrace/)
[![Stable](http://poser.pugx.org/open-telemetry/extension-propagator-cloudtrace/v/stable)](https://packagist.org/packages/open-telemetry/extension-propagator-cloudtrace/)

# OpenTelemetry Extension
### XCloudTrace Propagator
### CloudTrace Propagator

XCloudTrace is a propagator that supports the specification for the header "x-cloud-trace-context" used for trace context propagation across
service boundaries. (https://cloud.google.com/trace/docs/setup#force-trace). OpenTelemetry PHP XCloudTrace Propagator Extension provides
CloudTrace is a propagator that supports the specification for the header "x-cloud-trace-context" used for trace context propagation across
service boundaries. (https://cloud.google.com/trace/docs/setup#force-trace). OpenTelemetry PHP CloudTrace Propagator Extension provides
option to use it bi-directionally or one-way. One-way does not inject the header for downstream consumption, it only processes the incoming headers
and returns the correct span context. It only attaches to existing X-Cloud-Trace-Context traces and does not create downstream ones.
For one-way XCloudTrace:

For one-way CloudTrace:
```text
XCloudTracePropagator::getOneWayInstance()
CloudTracePropagator::getOneWayInstance()
```

For bi-directional XCloudTrace:
For bi-directional CloudTrace:
```text
XCloudTracePropagator::getInstance()
CloudTracePropagator::getInstance()
```

## Contributing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace OpenTelemetry\Extension\Propagator\XCloudTrace;
namespace OpenTelemetry\Extension\Propagator\CloudTrace;

/**
* This class contains utilities that are used by the XCloudTracePropagator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

use OpenTelemetry\Extension\Propagator\XCloudTrace\XCloudTracePropagator;
use OpenTelemetry\Extension\Propagator\CloudTrace\CloudTracePropagator;
use OpenTelemetry\SDK\Common\Configuration\KnownValues;
use OpenTelemetry\SDK\Registry;

Registry::registerTextMapPropagator(
KnownValues::VALUE_XCLOUD_TRACE,
XCloudTracePropagator::getInstance()
KnownValues::VALUE_CLOUD_TRACE,
CloudTracePropagator::getInstance()
);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "open-telemetry/extension-propagator-xcloudtrace",
"description": "XCloudTraceContext propagator extension for OpenTelemetry PHP.",
"keywords": ["opentelemetry", "otel", "tracing", "apm", "extension", "propagator", "xcloudtrace"],
"name": "open-telemetry/extension-propagator-cloudtrace",
"description": "CloudTraceContext propagator extension for OpenTelemetry PHP.",
"keywords": ["opentelemetry", "otel", "tracing", "apm", "extension", "propagator", "cloudtrace"],
"type": "library",
"support": {
"issues": "https://github.com/open-telemetry/opentelemetry-php/issues",
Expand All @@ -23,7 +23,7 @@
},
"autoload": {
"psr-4": {
"OpenTelemetry\\Extension\\Propagator\\XCloudTrace\\": "."
"OpenTelemetry\\Extension\\Propagator\\CloudTrace\\": "."
},
"files": [
"_register.php"
Expand Down
4 changes: 2 additions & 2 deletions src/SDK/Common/Configuration/KnownValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface KnownValues
public const VALUE_BAGGAGE = 'baggage';
public const VALUE_B3 = 'b3';
public const VALUE_B3_MULTI = 'b3multi';
public const VALUE_XCLOUD_TRACE = 'xcloudtrace';
public const VALUE_CLOUD_TRACE = 'cloudtrace';
public const VALUE_XRAY = 'xray';
public const VALUE_OTTRACE = 'ottrace';
public const VALUE_ALWAYS_ON = 'always_on';
Expand Down Expand Up @@ -106,7 +106,7 @@ interface KnownValues
self::VALUE_BAGGAGE, // W3C Baggage
self::VALUE_B3, // B3 Single
self::VALUE_B3_MULTI, // B3 Multi
self::VALUE_XCLOUD_TRACE, // GCP XCloudTraceContext
self::VALUE_CLOUD_TRACE, // GCP XCloudTraceContext
self::VALUE_XRAY, // AWS X-Ray (third party)
self::VALUE_OTTRACE, // OT Trace (third party)
self::VALUE_NONE, // No automatically configured propagator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

declare(strict_types=1);

namespace OpenTelemetry\Tests\Unit\Extension\Propagator\XCloudTrace;
namespace OpenTelemetry\Tests\Unit\Extension\Propagator\CloudTrace;

use OpenTelemetry\API\Trace\SpanContext;
use OpenTelemetry\API\Trace\SpanContextInterface;
use OpenTelemetry\API\Trace\TraceFlags;
use OpenTelemetry\Extension\Propagator\XCloudTrace\XCloudTraceFormatter;
use OpenTelemetry\Extension\Propagator\CloudTrace\CloudTraceFormatter;
use PHPUnit\Framework\TestCase;

/**
* @covers \OpenTelemetry\Extension\Propagator\XCloudTrace\XCloudTraceFormatter
* @covers \OpenTelemetry\Extension\Propagator\CloudTrace\CloudTraceFormatter
*/
class XCloudTraceFormatterTest extends TestCase
class CloudTraceFormatterTest extends TestCase
{

/**
* @dataProvider for_test_deserialize
*/
public function test_deserialize(string $header, string $traceId, string $spanId, int $sample) : void
{
$result = XCloudTraceFormatter::deserialize($header);
$result = CloudTraceFormatter::deserialize($header);
$this->assertEquals($result->getTraceId(), $traceId, "Given deserialize($header), traceId != $traceId (result={$result->getTraceId()}");
$this->assertEquals($result->getSpanId(), $spanId, "Given deserialize($header), spanId != $spanId (result={$result->getSpanId()}");
$this->assertEquals($result->getTraceFlags(), $sample, "Given deserialize($header), traceFlags != $sample (result={$result->getTraceFlags()}");
Expand All @@ -40,7 +40,7 @@ public function for_test_deserialize() : array
*/
public function test_serialize(SpanContextInterface $span, string $header) : void
{
$result = XCloudTraceFormatter::serialize($span);
$result = CloudTraceFormatter::serialize($span);
$this->assertEquals($result, $header, "Given serialize(header), result != $header (result=$result");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace OpenTelemetry\Tests\Unit\Extension\Propagator\XCloudTrace;
namespace OpenTelemetry\Tests\Unit\Extension\Propagator\CloudTrace;

use OpenTelemetry\API\Trace\SpanContext;
use OpenTelemetry\API\Trace\SpanContextInterface;
Expand All @@ -11,14 +11,14 @@
use OpenTelemetry\Context\Context;
use OpenTelemetry\Context\ContextInterface;
use OpenTelemetry\Context\Propagation\TextMapPropagatorInterface;
use OpenTelemetry\Extension\Propagator\XCloudTrace\XCloudTracePropagator;
use OpenTelemetry\Extension\Propagator\CloudTrace\CloudTracePropagator;
use OpenTelemetry\SDK\Trace\Span;
use PHPUnit\Framework\TestCase;

/**
* @covers \OpenTelemetry\Extension\Propagator\XCloudTrace\XCloudTracePropagator
* @covers \OpenTelemetry\Extension\Propagator\CloudTrace\XCloudTracePropagator
*/
class XCloudTracePropagatorTest extends TestCase
class CloudTracePropagatorTest extends TestCase
{
private const TRACE_ID_BASE16 = 'ff000000000000000000000000000041';
private const SPAN_ID_BASE16 = '0000000000000013';
Expand All @@ -32,7 +32,7 @@ class XCloudTracePropagatorTest extends TestCase

protected function setUp(): void
{
$this->xCloudTracePropagator = XCloudTracePropagator::getInstance();
$this->xCloudTracePropagator = CloudTracePropagator::getInstance();
[$this->xcloud] = $this->xCloudTracePropagator->fields();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

declare(strict_types=1);

namespace OpenTelemetry\Tests\Unit\Extension\Propagator\XCloudTrace;
namespace OpenTelemetry\Tests\Unit\Extension\Propagator\CloudTrace;

use OpenTelemetry\Extension\Propagator\XCloudTrace\Utils;
use OpenTelemetry\Extension\Propagator\CloudTrace\Utils;
use PHPUnit\Framework\TestCase;

/**
* @covers \OpenTelemetry\Extension\Propagator\XCloudTrace\Utils
* @covers \OpenTelemetry\Extension\Propagator\CloudTrace\Utils
*/
class UtilsTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/SDK/FactoryRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static function textMapPropagator(): array
['tracecontext'],
['b3multi'],
['b3'],
['xcloudtrace'],
['cloudtrace'],
];
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/SDK/Propagation/PropagatorFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use OpenTelemetry\Context\Propagation\MultiTextMapPropagator;
use OpenTelemetry\Context\Propagation\NoopTextMapPropagator;
use OpenTelemetry\Extension\Propagator\B3\B3Propagator;
use OpenTelemetry\Extension\Propagator\XCloudTrace\XCloudTracePropagator;
use OpenTelemetry\Extension\Propagator\CloudTrace\CloudTracePropagator;
use OpenTelemetry\SDK\Common\Configuration\KnownValues;
use OpenTelemetry\SDK\Common\Configuration\Variables;
use OpenTelemetry\SDK\Propagation\PropagatorFactory;
Expand Down Expand Up @@ -52,7 +52,7 @@ public static function propagatorsProvider(): array
[KnownValues::VALUE_BAGGAGE, BaggagePropagator::class],
[KnownValues::VALUE_TRACECONTEXT, TraceContextPropagator::class],
[KnownValues::VALUE_B3, B3Propagator::class],
[KnownValues::VALUE_XCLOUD_TRACE, XCloudTracePropagator::class],
[KnownValues::VALUE_CLOUD_TRACE, CloudTracePropagator::class],
[KnownValues::VALUE_B3_MULTI, B3Propagator::class],
[KnownValues::VALUE_NONE, NoopTextMapPropagator::class],
[sprintf('%s,%s', KnownValues::VALUE_B3, KnownValues::VALUE_BAGGAGE), MultiTextMapPropagator::class],
Expand Down

0 comments on commit 779a1b8

Please sign in to comment.