當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Context.MeasureSince方法代碼示例

本文整理匯總了Golang中github.com/heroku/slog.Context.MeasureSince方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.MeasureSince方法的具體用法?Golang Context.MeasureSince怎麽用?Golang Context.MeasureSince使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/heroku/slog.Context的用法示例。


在下文中一共展示了Context.MeasureSince方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: deliver

func (p *RiemannPoster) deliver(event *raidman.Event) {
	ctx := slog.Context{}
	defer func() { LogWithContext(ctx) }()

	start := time.Now()

	log.Printf("sending %#v\n", *event)

	err := p.riemann.Send(event)

	if err != nil {
		log.Println(ctx, "delivery error, trying to reconnect:", err)
		new_riemann, err := raidman.Dial("tcp", p.riemannAddress)
		if err == nil {
			log.Println("reconnected!")
			p.riemann = new_riemann
		} else {
			log.Println("reconnection failed:", err)
		}
	}

	ctx.MeasureSince("riemann_poster.time", start)
}
開發者ID:jonasschneider,項目名稱:lumbermill,代碼行數:23,代碼來源:riemann_poster.go

示例2: serveDrain


//.........這裏部分代碼省略.........
					chanGroup.points[EventsDyno] <- []interface{}{
						timestamp,
						id,
						what,
						"R",
						de.Code,
						string(msg),
						dynoType(what),
					}

				// Dyno log-runtime-metrics memory messages
				case bytes.Contains(msg, dynoMemMsgSentinel):
					ctx.Count("lines.dyno.mem", 1)
					dm := dynoMemMsg{}
					err := logfmt.Unmarshal(msg, &dm)
					if err != nil {
						log.Printf("logfmt unmarshal error: %s\n", err)
						continue
					}
					if dm.Source != "" {
						chanGroup.points[DynoMem] <- []interface{}{
							timestamp,
							id,
							dm.Source,
							dm.MemoryCache,
							dm.MemoryPgpgin,
							dm.MemoryPgpgout,
							dm.MemoryRSS,
							dm.MemorySwap,
							dm.MemoryTotal,
							dynoType(dm.Source),
						}
					}

					// Dyno log-runtime-metrics load messages
				case bytes.Contains(msg, dynoLoadMsgSentinel):
					ctx.Count("lines.dyno.load", 1)
					dm := dynoLoadMsg{}
					err := logfmt.Unmarshal(msg, &dm)
					if err != nil {
						log.Printf("logfmt unmarshal error: %s\n", err)
						continue
					}
					if dm.Source != "" {
						chanGroup.points[DynoLoad] <- []interface{}{
							timestamp,
							id,
							dm.Source,
							dm.LoadAvg1Min,
							dm.LoadAvg5Min,
							dm.LoadAvg15Min,
							dynoType(dm.Source),
						}
					}

				// unknown
				default:
					ctx.Count("lines.unknown.heroku", 1)
					if Debug {
						log.Printf("Unknown Heroku Line - Header: PRI: %s, Time: %s, Hostname: %s, Name: %s, ProcId: %s, MsgId: %s - Body: %s",
							header.PrivalVersion,
							header.Time,
							header.Hostname,
							header.Name,
							header.Procid,
							header.Msgid,
							string(msg),
						)
					}
				}
			}

		// non heroku lines
		default:
			ctx.Count("lines.unknown.user", 1)
			if Debug {
				log.Printf("Unknown User Line - Header: PRI: %s, Time: %s, Hostname: %s, Name: %s, ProcId: %s, MsgId: %s - Body: %s",
					header.PrivalVersion,
					header.Time,
					header.Hostname,
					header.Name,
					header.Procid,
					header.Msgid,
					string(msg),
				)
			}
		}
	}
	ctx.MeasureSince("lines.parse.time", parseStart)

	// If we are told to close the connection after the reply, do so.
	select {
	case <-connectionCloser:
		w.Header().Set("Connection", "close")
	default:
		//Nothing
	}

	w.WriteHeader(http.StatusNoContent)
}
開發者ID:ukd1,項目名稱:lumbermill,代碼行數:101,代碼來源:drain.go


注:本文中的github.com/heroku/slog.Context.MeasureSince方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。