File tree Expand file tree Collapse file tree 3 files changed +73
-0
lines changed
spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/micrometertracing Expand file tree Collapse file tree 3 files changed +73
-0
lines changed Original file line number Diff line number Diff line change
1
+ package org.springframework.boot.docs.actuator.micrometertracing.baggage
2
+
3
+ import io.micrometer.tracing.Tracer
4
+ import org.springframework.stereotype.Component
5
+
6
+ @Component
7
+ class CreatingBaggage (private val tracer : Tracer ) {
8
+
9
+ fun doSomething () {
10
+ tracer.createBaggageInScope(" baggage1" , " value1" ).use {
11
+ // Business logic
12
+ }
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2012-2022 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.micrometertracing.creatingspans
18
+
19
+ import io.micrometer.observation.Observation
20
+ import io.micrometer.observation.ObservationRegistry
21
+ import org.springframework.stereotype.Component
22
+
23
+ @Component
24
+ class CustomObservation (private val observationRegistry : ObservationRegistry ) {
25
+
26
+ fun someOperation () {
27
+ Observation .createNotStarted(" some-operation" , observationRegistry)
28
+ .lowCardinalityKeyValue(" some-tag" , " some-value" )
29
+ .observe {
30
+ // Business logic ...
31
+ }
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ package org.springframework.boot.docs.actuator.micrometertracing.gettingstarted
2
+
3
+ import org.apache.commons.logging.Log
4
+ import org.apache.commons.logging.LogFactory
5
+ import org.springframework.boot.autoconfigure.SpringBootApplication
6
+ import org.springframework.boot.runApplication
7
+ import org.springframework.web.bind.annotation.RequestMapping
8
+ import org.springframework.web.bind.annotation.RestController
9
+
10
+ @RestController
11
+ @SpringBootApplication
12
+ class MyApplication {
13
+
14
+ private val logger: Log = LogFactory .getLog(MyApplication ::class .java)
15
+
16
+
17
+ @RequestMapping(" /" )
18
+ fun hello (): String {
19
+ logger.info(" home() has been called" )
20
+ return " Hello, World!"
21
+ }
22
+ }
23
+
24
+ fun main (args : Array <String >) {
25
+ runApplication<MyApplication >(* args)
26
+ }
You can’t perform that action at this time.
0 commit comments