File tree Expand file tree Collapse file tree 3 files changed +107
-0
lines changed
documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/micrometertracing Expand file tree Collapse file tree 3 files changed +107
-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.micrometertracing.baggage
18
+
19
+ import io.micrometer.tracing.Tracer
20
+ import org.springframework.stereotype.Component
21
+
22
+ @Component
23
+ class CreatingBaggage (private val tracer : Tracer ) {
24
+
25
+ fun doSomething () {
26
+ tracer.createBaggageInScope(" baggage1" , " value1" ).use {
27
+ // Business logic
28
+ }
29
+ }
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.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
+
34
+ }
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.micrometertracing.gettingstarted
18
+
19
+ import org.apache.commons.logging.Log
20
+ import org.apache.commons.logging.LogFactory
21
+ import org.springframework.boot.autoconfigure.SpringBootApplication
22
+ import org.springframework.boot.runApplication
23
+ import org.springframework.web.bind.annotation.RequestMapping
24
+ import org.springframework.web.bind.annotation.RestController
25
+
26
+ @RestController
27
+ @SpringBootApplication
28
+ class MyApplication {
29
+
30
+ private val logger: Log = LogFactory .getLog(MyApplication ::class .java)
31
+
32
+ @RequestMapping(" /" )
33
+ fun hello (): String {
34
+ logger.info(" home() has been called" )
35
+ return " Hello, World!"
36
+ }
37
+
38
+ }
39
+
40
+ fun main (args : Array <String >) {
41
+ runApplication<MyApplication >(* args)
42
+ }
You can’t perform that action at this time.
0 commit comments