Skip to content

Commit b56403b

Browse files
committed
Merge branch '3.5.x'
Closes gh-46799
2 parents 03fac30 + b055d7b commit b56403b

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.docs.actuator.loggers.opentelemetry
18+
19+
import io.opentelemetry.api.OpenTelemetry
20+
import io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender
21+
import org.springframework.beans.factory.InitializingBean
22+
import org.springframework.stereotype.Component
23+
24+
@Component
25+
class OpenTelemetryAppenderInitializer(
26+
private val openTelemetry: OpenTelemetry
27+
) : InitializingBean {
28+
29+
override fun afterPropertiesSet() = OpenTelemetryAppender.install(openTelemetry)
30+
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.docs.actuator.observability
18+
19+
import io.micrometer.observation.Observation
20+
import io.micrometer.observation.ObservationRegistry;
21+
22+
import org.springframework.stereotype.Component
23+
24+
@Component
25+
class MyCustomObservation(private val observationRegistry: ObservationRegistry) {
26+
27+
fun doSomething() {
28+
Observation.createNotStarted("doSomething", observationRegistry)
29+
.lowCardinalityKeyValue("locale", "en-US")
30+
.highCardinalityKeyValue("userId", "42")
31+
.observe {
32+
// Execute business logic here
33+
}
34+
}
35+
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.docs.actuator.observability.preventingobservations
18+
19+
import io.micrometer.observation.Observation.Context
20+
import io.micrometer.observation.ObservationPredicate
21+
import org.springframework.stereotype.Component
22+
23+
@Component
24+
class MyObservationPredicate : ObservationPredicate {
25+
26+
override fun test(name: String, context: Context): Boolean {
27+
return !name.contains("denied")
28+
}
29+
30+
}

0 commit comments

Comments
 (0)