Skip to content

Commit 912584d

Browse files
committed
small fixes
1 parent b691299 commit 912584d

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

contrib/OtlpGrpc/Exporter.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Exporter implements Trace\Exporter
6363
private $client;
6464

6565
/**
66-
* Exporter constructor.
66+
* OTLP GRPC Exporter Constructor
6767
* @param string $serviceName
6868
*/
6969
public function __construct(
@@ -106,8 +106,7 @@ public function export(iterable $spans): int
106106
foreach ($spans as $span) {
107107
array_push($convertedSpans, $this->spanConverter->convert($span));
108108
}
109-
echo "$convertedSpans";
110-
109+
111110
$request= new V1\ExportTraceServiceRequest();
112111
$request->setResourceSpans($convertedSpans);
113112

contrib/OtlpGrpc/SpanConverter.php

+11-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Opentelemetry\Proto\Trace\V1\Span as CollectorSpan;
99
use Opentelemetry\Proto\Trace\V1\Status\StatusCode;
1010
use Opentelemetry\Proto\Trace\V1\Status;
11+
use Opentelemetry\Proto\Common\V1\InstrumentationLibrary
1112

1213
class SpanConverter
1314
{
@@ -44,7 +45,14 @@ private function sanitiseTagValue($value)
4445
}
4546

4647
public function convert(Span $span)
47-
{
48+
{
49+
$instrumentation_library_spans=[];
50+
$il=new InstrumentationLibrary();
51+
$name=$il->getName();
52+
$version=$il->getVersion();
53+
54+
55+
4856
$spanParent = $span->getParent();
4957
$row = [
5058
'id' => $span->getContext()->getSpanId(),
@@ -56,6 +64,7 @@ public function convert(Span $span)
5664
'name' => $span->getSpanName(),
5765
'timestamp' => (int) ($span->getStartEpochTimestamp() / 1e3), // RealtimeClock in microseconds
5866
'duration' => (int) (($span->getEnd() - $span->getStart()) / 1e3), // Diff in microseconds
67+
'trace_state' => $span->getContext();
5968

6069
];
6170

@@ -87,10 +96,6 @@ public function convert(Span $span)
8796
}
8897
if (!array_key_exists('status', $row)) {
8998
$proto_status = StatusCode::STATUS_CODE_OK;
90-
//////
91-
/////HIGHLIGHTED
92-
////
93-
///
9499
if ($span->getStatus()->getCanonicalStatusCode() === "ERROR") {
95100
$proto_status = StatusCode::STATUS_CODE_ERROR;
96101
}
@@ -105,4 +110,4 @@ public function convert(Span $span)
105110
// $key->setKey("id")
106111
// $value=new AnyValue();
107112
// $value->setStringValue($span->getContext()->getSpanId());
108-
// $key->setValue($value);
113+
// $key->setValue($value);

0 commit comments

Comments
 (0)