Merge pull request #34004 from eddumelendez

* pr/34004:
  Add property `headers` in `OtlpProperties`

Closes gh-34004
This commit is contained in:
Moritz Halbritter
2023-01-31 09:41:19 +01:00
4 changed files with 29 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,6 +41,11 @@ public class OtlpProperties extends StepRegistryProperties {
*/
private Map<String, String> resourceAttributes;
/**
* Headers for the exported metrics.
*/
private Map<String, String> headers;
public String getUrl() {
return this.url;
}
@@ -57,4 +62,12 @@ public class OtlpProperties extends StepRegistryProperties {
this.resourceAttributes = resourceAttributes;
}
public Map<String, String> getHeaders() {
return this.headers;
}
public void setHeaders(Map<String, String> headers) {
this.headers = headers;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,4 +48,9 @@ class OtlpPropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapter<Ot
return get(OtlpProperties::getResourceAttributes, OtlpConfig.super::resourceAttributes);
}
@Override
public Map<String, String> headers() {
return get(OtlpProperties::getHeaders, OtlpConfig.super::headers);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,4 +44,11 @@ class OtlpPropertiesConfigAdapterTests {
"boot-service");
}
@Test
void whenPropertiesHeadersIsSetAdapterHeadersReturnsIt() {
OtlpProperties properties = new OtlpProperties();
properties.setHeaders(Map.of("header", "value"));
assertThat(new OtlpPropertiesConfigAdapter(properties).headers()).containsEntry("header", "value");
}
}

View File

@@ -932,7 +932,7 @@ bom {
]
}
}
library("Micrometer", "1.10.3") {
library("Micrometer", "1.11.0-SNAPSHOT") {
group("io.micrometer") {
modules = [
"micrometer-registry-stackdriver" {