|
| 1 | +/* |
| 2 | + * Copyright 2024 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 | + */ |
1 | 16 | package org.springframework.modulith.observability;
|
2 | 17 |
|
3 |
| -import io.micrometer.observation.Observation; |
4 |
| -import org.aopalliance.intercept.MethodInvocation; |
| 18 | +import io.micrometer.observation.Observation.Context; |
5 | 19 |
|
| 20 | +import org.aopalliance.intercept.MethodInvocation; |
6 | 21 | import org.springframework.core.env.Environment;
|
| 22 | +import org.springframework.util.Assert; |
7 | 23 |
|
8 | 24 | /**
|
9 | 25 | * A {@link Observation.Context} for Modulithic applications.
|
10 | 26 | *
|
11 | 27 | * @author Marcin Grzejsczak
|
| 28 | + * @author Oliver Drotbohm |
12 | 29 | * @since 1.4
|
13 | 30 | */
|
14 |
| -public class ModulithContext extends Observation.Context { |
| 31 | +public class ModulithContext extends Context { |
15 | 32 |
|
16 |
| - private final ObservedModule module; |
| 33 | + private final ObservedModule module; |
| 34 | + private final MethodInvocation invocation; |
| 35 | + private final String applicationName; |
17 | 36 |
|
18 |
| - private final MethodInvocation invocation; |
| 37 | + public ModulithContext(ObservedModule module, MethodInvocation invocation, Environment environment) { |
19 | 38 |
|
20 |
| - private final String applicationName; |
| 39 | + Assert.notNull(module, "ObservedModule must not be null!"); |
| 40 | + Assert.notNull(invocation, "MethodInvocation must not be null!"); |
| 41 | + Assert.notNull(environment, "Environment must not be null!"); |
21 | 42 |
|
22 |
| - public ModulithContext(ObservedModule module, MethodInvocation invocation, Environment environment) { |
23 |
| - this.module = module; |
24 |
| - this.invocation = invocation; |
25 |
| - this.applicationName = environment.getProperty("spring.application.name"); |
26 |
| - } |
| 43 | + this.module = module; |
| 44 | + this.invocation = invocation; |
| 45 | + this.applicationName = environment.getProperty("spring.application.name"); |
| 46 | + } |
27 | 47 |
|
28 |
| - public ObservedModule getModule() { |
29 |
| - return module; |
30 |
| - } |
| 48 | + public ObservedModule getModule() { |
| 49 | + return module; |
| 50 | + } |
31 | 51 |
|
32 |
| - public MethodInvocation getInvocation() { |
33 |
| - return invocation; |
34 |
| - } |
| 52 | + public MethodInvocation getInvocation() { |
| 53 | + return invocation; |
| 54 | + } |
35 | 55 |
|
36 |
| - public String getApplicationName() { |
37 |
| - return applicationName; |
38 |
| - } |
| 56 | + public String getApplicationName() { |
| 57 | + return applicationName; |
| 58 | + } |
39 | 59 | }
|
0 commit comments