Skip to content

Commit 847a356

Browse files
committed
Updated Readme and composer.json
1 parent 7a60506 commit 847a356

File tree

4 files changed

+60
-50
lines changed

4 files changed

+60
-50
lines changed

src/Exporter/Instana/README.md

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,76 @@
1-
OpenTelemetry Instana Propagator
1+
[![Releases](https://img.shields.io/badge/releases-purple)](https://github.com/opentelemetry-php/contrib-instana-exporter/releases)
2+
[![Issues](https://img.shields.io/badge/issues-pink)](https://www.ibm.com/support/pages/instana-support)
3+
[![Source](https://img.shields.io/badge/source-contrib-green)](https://github.com/open-telemetry/opentelemetry-php-contrib/tree/main/src/Exporter/Instana)
4+
[![Mirror](https://img.shields.io/badge/mirror-opentelemetry--php--contrib-blue)](https://github.com/opentelemetry-php/contrib-instana-exporter)
5+
[![Latest Version](http://poser.pugx.org/open-telemetry/opentelemetry-instana-exporter/v/unstable)](https://packagist.org/packages/open-telemetry/opentelemetry-instana-exporter/)
6+
[![Stable](http://poser.pugx.org/open-telemetry/opentelemetry-instana-exporter/v/stable)](https://packagist.org/packages/open-telemetry/opentelemetry-instana-exporter/)
27

3-
The OpenTelemetry Propagator for Instana provides HTTP header propagation for systems that are using IBM Observability by Instana.
4-
This propagator translates the Instana trace correlation headers (`X-INSTANA-T/X-INSTANA-S/X-INSTANA-L`) into the OpenTelemetry `SpanContext`, and vice versa.
5-
It does not handle `TraceState`.
8+
This is a read-only subtree split of https://github.com/open-telemetry/opentelemetry-php-contrib.
69

10+
# Instana OpenTelemetry PHP Exporter
711

8-
## Installation
12+
Instana exporter for OpenTelemetry.
913

10-
```sh
11-
composer require open-telemetry/opentelemetry-propagation-instana
12-
```
13-
14-
## Usage
14+
## Documentation
1515

16-
```
17-
$propagator = InstanaMultiPropagator::getInstance();
18-
```
16+
https://www.ibm.com/docs/en/instana-observability/current?topic=php-opentelemetry-exporter
1917

20-
Both of the above have extract and inject methods available to extract and inject respectively into the header.
18+
## Installing via Composer
2119

22-
## Propagator Details
20+
Install Composer in a common location or in your project
2321

24-
There are three headers that the propagator handles: `X-INSTANA-T` (the trace ID), `X-INSTANA-S` (the parent span ID), and `X-INSTANA-L` (the sampling level).
22+
```bash
23+
curl -s https://getcomposer.org/installer | php
24+
```
2525

26-
Example header triplet:
26+
Install via Composer
2727

28-
* `X-INSTANA-T: 80f198ee56343ba864fe8b2a57d3eff7`,
29-
* `X-INSTANA-S: e457b5a2e4d86bd1`,
30-
* `X-INSTANA-L: 1`.
28+
```bash
29+
composer require instana/contrib-instana-exporter
30+
```
3131

32-
A short summary for each of the headers is provided below. More details are available at <https://www.ibm.com/docs/en/obi/current?topic=monitoring-traces#tracing-headers>.
32+
## Usage
3333

34-
### X-INSTANA-T -- trace ID
3534

36-
* A string of either 16 or 32 characters from the alphabet `0-9a-f`, representing either a 64 bit or 128 bit ID.
37-
* This header corresponds to the [OpenTelemetry TraceId](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#spancontext).
38-
* If the propagator receives an X-INSTANA-T header value that is shorter than 32 characters when _extracting_ headers into the OpenTelemetry span context, it will left-pad the string with the character "0" to length 32.
39-
* No length transformation is applied when _injecting_ the span context into headers.
35+
Utilizing the OpenTelemetry PHP SDK, we can send spans natively to Instana, by providing an OpenTelemetry span processor our `SpanExporterInterface`.
4036

41-
### X-INSTANA-S -- parent span ID
37+
This can be manually constructed, or created from the `SpanExporterFactory`. See the factory implementation for how to manually construct the `SpanExporter`. The factory reads from two environment variables which can be set according, else will fallback onto the following defaults
4238

43-
* Format: A string of 16 characters from the alphabet `0-9a-f`, representing a 64 bit ID.
44-
* This header corresponds to the [OpenTelemetry SpanId](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#spancontext).
39+
```bash
40+
INSTANA_AGENT_HOST=127.0.0.1
41+
INSTANA_AGENT_PORT=42699
42+
```
4543

46-
### X-INSTANA-L - sampling level
44+
The service name that is visible in the Instana UI can be configured with the following environment variables. OpenTelemetry provides `OTEL_SERVICE_NAME` (see documentation [here](https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_service_name)) as a way to customize this within the SDK. We also provide `INSTANA_SERVICE_NAME` which will be taken as the highest precedence.
4745

48-
* The only two valid values are `1` and `0`.
49-
* A level of `1` means that this request is to be sampled, a level of `0` means that the request should not be sampled.
50-
* This header corresponds to the sampling bit of the [OpenTelemetry TraceFlags](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#spancontext).
46+
```bash
47+
INSTANA_SERVICE_NAME=custom-service-name
48+
```
5149

52-
## Useful links
50+
## Example
5351

54-
* For more information on Instana, visit <https://www.instana.com/> and [Instana' documentation](https://www.ibm.com/docs/en/obi/current).
55-
* For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
52+
```php
53+
use OpenTelemetry\SDK\Trace\SpanProcessor\SimpleSpanProcessor;
54+
use OpenTelemetry\SDK\Trace\TracerProvider;
5655

57-
## Installing dependencies and executing tests
56+
$tracerProvider = new TracerProvider(
57+
new SimpleSpanProcessor(
58+
Registry::spanExporterFactory("instana")->create()
59+
)
60+
);
61+
$tracer = $tracerProvider->getTracer('io.instana.opentelemetry.php');
5862

59-
From Instana subdirectory:
63+
$span = $tracer->spanBuilder('root')->startSpan();
64+
$span->setAttribute('remote_ip', '1.2.3.4')
65+
->setAttribute('country', 'CAN');
66+
$span->addEvent('generated_session', [
67+
'id' => md5((string) microtime(true)),
68+
]);
69+
$span->end();
6070

61-
``` sh
62-
$ composer install
63-
$ ./vendor/bin/phpunit tests
71+
$tracerProvider->shutdown();
6472
```
73+
74+
## Contributions
75+
76+
This repo is maintained by IBM Instana and is read-only. Issues and other contributions should be reported as part of standard [Instana product support](https://www.ibm.com/support/pages/instana-support).

src/Exporter/Instana/composer.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,10 @@
1111
],
1212
"type": "library",
1313
"support": {
14-
"issues": "https://github.com/instana/opentelemetry-php-exporter/issues",
15-
"source": "https://github.com/instana/opentelemetry-php-exporter",
14+
"issues": "https://www.ibm.com/support/pages/instana-support",
15+
"source": "https://github.com/open-telemetry/opentelemetry-php-contrib/main/src/Exporter/Instana",
1616
"docs": "https://www.ibm.com/docs/en/instana-observability/current?topic=opentelemetry-php-exporter"
1717
},
18-
"license": "Apache-2.0",
19-
"authors": [
20-
{
21-
"name": "Instana contributors",
22-
"homepage": "https://github.com/instana/opentelemetry-php-exporter/graphs/contributors"
23-
}
24-
],
2518
"require": {
2619
"php": "^8.1",
2720
"open-telemetry/api": "^1.1",

src/Exporter/Instana/src/InstanaTransport.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,18 @@ class InstanaTransport implements TransportInterface
3535
private Client $client;
3636
private ?string $agent_uuid = null;
3737
private ?int $pid = null;
38+
39+
// @phpstan-ignore property.onlyWritten
3840
private array $secrets = [];
41+
// @phpstan-ignore property.onlyWritten
3942
private array $tracing = [];
4043

4144
private bool $closed = true;
4245
private array $headers = [];
4346

4447
public function __construct(
4548
private readonly string $endpoint,
49+
// @phpstan-ignore property.onlyWritten
4650
private readonly float $timeout = 0.0
4751
) {
4852
$this->headers += ['Content-Type' => self::CONTENT_TYPE];

src/Exporter/Instana/src/SpanConverter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ private function convertSpan(SpanDataInterface $span): array
157157
!in_array($matches[2], $extraResponseHeaders);
158158
}, ARRAY_FILTER_USE_KEY);
159159

160+
// @phpstan-ignore-next-line
160161
foreach ($keys as $k => $_v) {
161162
unset($instanaSpan['data']['sdk']['custom']['tags']['attributes'][$k]);
162163
}

0 commit comments

Comments
 (0)