@@ -74,6 +74,8 @@ String getKey() {
7474 }
7575 }
7676
77+ private static String appEngineLabelPrefix = "appengine.googleapis.com/" ;
78+
7779 private static Map <String , Label []> resourceTypeWithLabels ;
7880
7981 static {
@@ -198,11 +200,12 @@ private static List<LoggingEnhancer> getEnhancers(Resource resourceType) {
198200 // Trace logging enhancer is supported on GAE Flex and Standard.
199201 case GaeAppFlex :
200202 enhancers = new ArrayList <>();
201- enhancers .add (new LabelLoggingEnhancer (Collections .singletonList (Label .InstanceName )));
202- enhancers .add (new TraceLoggingEnhancer ());
203+ enhancers .add (new LabelLoggingEnhancer (
204+ appEngineLabelPrefix , Collections .singletonList (Label .InstanceName )));
205+ enhancers .add (new TraceLoggingEnhancer (appEngineLabelPrefix ));
203206 break ;
204207 case GaeAppStandard :
205- enhancers .add (new TraceLoggingEnhancer ());
208+ enhancers .add (new TraceLoggingEnhancer (appEngineLabelPrefix ));
206209 break ;
207210 default :
208211 enhancers = Collections .emptyList ();
@@ -218,9 +221,11 @@ private static List<LoggingEnhancer> getEnhancers(Resource resourceType) {
218221 * @see <a href="https://cloud.google.com/logging/docs/api/v2/resource-list">Logging Labels</a>
219222 */
220223 static class LabelLoggingEnhancer implements LoggingEnhancer {
224+ String prefix ;
221225 List <Label > labels ;
222226
223- LabelLoggingEnhancer (List <Label > labels ) {
227+ LabelLoggingEnhancer (String prefix , List <Label > labels ) {
228+ this .prefix = prefix != null ? prefix : "" ;
224229 this .labels = labels ;
225230 }
226231
@@ -229,7 +234,7 @@ public void enhanceLogEntry(Builder logEntry) {
229234 for (Label label : labels ) {
230235 String labelValue = MonitoredResourceUtil .getValue (label );
231236 if (labelValue != null ) {
232- logEntry .addLabel (label .getKey (), labelValue );
237+ logEntry .addLabel (prefix + label .getKey (), labelValue );
233238 }
234239 }
235240 }
0 commit comments