File tree Expand file tree Collapse file tree 3 files changed +97
-0
lines changed
documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator Expand file tree Collapse file tree 3 files changed +97
-0
lines changed Original file line number Diff line number Diff line change 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 number Diff line number Diff line change 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 number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments