Skip to content

Commit

Permalink
Use endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
TQJADE committed Aug 27, 2024
1 parent dd3b49c commit f38711a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ private[spark] class OpenTelemetryPushReporter(
registry: MetricRegistry,
pollInterval: Int = 10,
pollUnit: TimeUnit = TimeUnit.SECONDS,
host: String = "http://localhost",
port: String = "4317",
endpoint: String = "http://localhost:4317",
headersMap: Map[String, String] = Map(),
attributesMap: Map[String, String] = Map(),
trustedCertificatesPath: String,
Expand Down Expand Up @@ -85,8 +84,7 @@ private[spark] class OpenTelemetryPushReporter(
Files.readAllBytes(Paths.get(certificatePemPath)))
}

val grpcEndpoint = host + ":" + port
otlpGrpcMetricExporterBuilder.setEndpoint(grpcEndpoint)
otlpGrpcMetricExporterBuilder.setEndpoint(endpoint)

val arrtributesBuilder = Attributes.builder()
for ((key, value) <- attributesMap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ private[spark] class OpenTelemetryPushSink(val property: Properties, val registr
val OPEN_TELEMETRY_KEY_UNIT = "unit"
val OPEN_TELEMETRY_DEFAULT_PERIOD = "10"
val OPEN_TELEMETRY_DEFAULT_UNIT = "SECONDS"
val OPEN_TELEMETRY_KEY_HOST = "host"
val OPEN_TELEMETRY_KEY_PORT = "port"
val OPEN_TELEMETRY_KEY_ENDPOINT = "endpoint"
val GRPC_METRIC_EXPORTER_HEADER_KEY = "grpc.metric.exporter.header"
val GRPC_METRIC_EXPORTER_ATTRIBUTES_KEY = "grpc.metric.exporter.attributes"
val TRUSTED_CERTIFICATE_PATH = "trusted.certificate.path"
Expand All @@ -69,8 +68,7 @@ private[spark] class OpenTelemetryPushSink(val property: Properties, val registr
.getProperty(OPEN_TELEMETRY_KEY_UNIT, OPEN_TELEMETRY_DEFAULT_UNIT)
.toUpperCase(Locale.ROOT))

val host = property.getProperty(OPEN_TELEMETRY_KEY_HOST)
val port = property.getProperty(OPEN_TELEMETRY_KEY_PORT)
val endpoint = property.getProperty(OPEN_TELEMETRY_KEY_ENDPOINT)

val headersMap =
OpenTelemetryPushSink.fetchMapFromProperties(property, GRPC_METRIC_EXPORTER_HEADER_KEY)
Expand All @@ -88,8 +86,7 @@ private[spark] class OpenTelemetryPushSink(val property: Properties, val registr
registry,
pollInterval = pollPeriod,
pollUnit,
host,
port,
endpoint,
headersMap,
attributesMap,
trustedCertificatesPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class OpenTelemetryPushSinkSuite

test("OpenTelemetry sink with one counter added") {
val props = new Properties
props.put("host", "http://127.0.0.1")
props.put("port", "10086")
props.put("endpoint", "http://127.0.0.1:10086")
val registry = new MetricRegistry
val sink = new OpenTelemetryPushSink(props, registry)
sink.start()
Expand Down

0 comments on commit f38711a

Please sign in to comment.