1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00

1 Commits

Author SHA1 Message Date
Tyler Yahn 6cb0e90c0e Generate gRPC Client target parsing func (#7424)
In order to add [gRPC server attributes for exporter
observability](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/otel/sdk-metrics.md#metric-otelsdkexporterspaninflight),
this information needs to be parsed into a host and port. The added
generated files provides `ParseCanonicalTarget` for this functionality.

This is added as a generated template as it is expected to be needed for
all OTLP exporters (e.g. #7404, #7353).

Split from work added to #7404 

cc @yumosx 

### Benchamarks

```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                                 │ otlptracegrpc-observ-target.bmark.result │
                                 │                  sec/op                  │
ParseTarget/HostName-8                                         80.90n ±  1%
ParseTarget/HostPort-8                                         123.2n ±  4%
ParseTarget/IPv4WithoutPort-8                                  94.25n ±  2%
ParseTarget/IPv4WithPort-8                                     136.2n ±  1%
ParseTarget/IPv6Bare-8                                         195.5n ±  2%
ParseTarget/IPv6Bracket-8                                      191.2n ±  3%
ParseTarget/IPv6WithPort-8                                     128.6n ±  4%
ParseTarget/UnixSocket-8                                       15.73n ±  4%
ParseTarget/UnixAbstractSocket-8                               15.71n ±  6%
ParseTarget/Passthrough-8                                      129.3n ± 18%
geomean                                                        84.98n

                                 │ otlptracegrpc-observ-target.bmark.result │
                                 │                   B/op                   │
ParseTarget/HostName-8                                         48.00 ± 0%
ParseTarget/HostPort-8                                         48.00 ± 0%
ParseTarget/IPv4WithoutPort-8                                  16.00 ± 0%
ParseTarget/IPv4WithPort-8                                     48.00 ± 0%
ParseTarget/IPv6Bare-8                                         16.00 ± 0%
ParseTarget/IPv6Bracket-8                                      16.00 ± 0%
ParseTarget/IPv6WithPort-8                                     48.00 ± 0%
ParseTarget/UnixSocket-8                                       0.000 ± 0%
ParseTarget/UnixAbstractSocket-8                               0.000 ± 0%
ParseTarget/Passthrough-8                                      48.00 ± 0%
geomean                                                                   ¹
¹ summaries must be >0 to compute geomean

                                 │ otlptracegrpc-observ-target.bmark.result │
                                 │                allocs/op                 │
ParseTarget/HostName-8                                         1.000 ± 0%
ParseTarget/HostPort-8                                         1.000 ± 0%
ParseTarget/IPv4WithoutPort-8                                  1.000 ± 0%
ParseTarget/IPv4WithPort-8                                     1.000 ± 0%
ParseTarget/IPv6Bare-8                                         1.000 ± 0%
ParseTarget/IPv6Bracket-8                                      1.000 ± 0%
ParseTarget/IPv6WithPort-8                                     1.000 ± 0%
ParseTarget/UnixSocket-8                                       0.000 ± 0%
ParseTarget/UnixAbstractSocket-8                               0.000 ± 0%
ParseTarget/Passthrough-8                                      1.000 ± 0%
geomean                                                                   ¹
¹ summaries must be >0 to compute geomean
```
2025-09-29 07:33:08 -07:00